我正在尝试链接嵌套.then函数并调用成功函数,但回调是在启动时调用.
//public method fn
function fn(callback) {
//calling the 1st API request
fn1()
.then(function(response) {
//2nd API request function
call1(response);
}, function(error) {
return $q.reject({
responseStatus: error.status
});
})
// Returning response
.then(function(response) {
callback({
responseStatus: 200
});
}, function(error) {
callback({
responseStatus: 500
});
});
}
function call1(response) {
//2nd API
fn2()
.then(function(response) {
//3rd API request function
call2(response);
}, function(error) {
return $q.reject({
responseStatus: error.status
});
});
}
function call2(response) {
//3rd API request
fn3()
.then(function(response) {
return …Run Code Online (Sandbox Code Playgroud)