I need to do two $http.post requests in my code. The first one retrieve a key that is used by the second one for looking up a SQL database.
At the moment, they're nested like this :
$http.post(...)
.success(function(data, status) {
//Do something
$http.post(...)
.success(function(data, status) {
//Do something else
}
}
I highly doubt that this is the correct way of doing this. Can't I make the second request wait for the first one, and end up with something like :
$http.post(...)
.success(function(data, status) {
//Do something
}
$http.post(...)
.success(function(data, status) {
//Do something else
}
generatorsin EcmaScript 6 orasync functionsin EcmaScript 7 which are able to pause execution, so you can write async tasks in synchronous manner, but in ES5, the obvious and "best" way are callbacks.