I'm new to use promise and Q, I'm sure I'm not doing correctly,
please give me some suggestion,
can I use fcall
inside fcall
? because there is a for loop I want to make sure each item image[i]
process a list promise function flow..
I need the response
from beginning to end, input to each promise function then pass to next flow the end return to client side,
but I don't get how to deal with the loop
var response = {};
Q.fcall(function() {
// validate request ...
return response;
})
.then(function(response) {
// save file
for (var i = 0; i < images.length; i++) {
Q.fcall(function() {
// do something with images[i]
return response;
})
.then(function(response) {
// do something with images[i]
return response;
})
.fail(function(error, response) {
response.error = error;
res.send(response);
})
.done(function(response) {
return response;
})
}
return response; << I want this response append data from above loop if above loop all success, then to next flow save db query, if one fail then res.send(), not execute all after
})
.then(function(response) {
// save db query ...
return response
})
.fail(function(error, response) {
response.error = error;
res.send(response);
}).done(function(response) {
res.send(response);
});