I'm struggleling since hours trying to understand how is working $q. I'm trying to make it works with a function from the google.maps api but I'm definitely not able to answer it by myself or maybe I totally don't understand $q. I hope you'll be able to help me or at least give me some explanation.
Here is a very simple example of what I would like to do :
var geocoder = new google.maps.Geocoder();
let promise1 = geocoder.geocode({address: "someAddress"});
let promise2 = geocoder.geocode({address: "someOtherAddress"});
$q.all([promise1, promise2]).then(data => {
console.log(data)
});
//The ouput I get is : [undefined, undefined] but it's definitely not what I expect :P
Where am I wrong ? Here is the original async method from google api which works fine.
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: "someAddress"}, function(response, status){
if(status === 'ok')
//Do what I need with the response
else
//Do something else
});
The thing is I want to do do something with multiple requests, not only one. So I need to store all the responses (and wait for them to be stored as it's an async function) before doing something. That's why I try to use $q to reach my goal.
PS: Maybe it's a double thread because I saw a lot of discussion about $q but even after hours of researches I can't find an issue... So please don't tell me to google it.
Thanks by advance for your help !