I want to send an array of messages sequentially (in the same order of the given array) to the Messenger Send API.
When I am sending two messages, like so:
import Promise from 'bluebird';
const message1 = {...};
const message2 = {...};
const send = (message) => {
return () => {sendAPI.post('/', message)};
}
let promises = [ send(message1), send(message2) ];
Promise.each(promises, (promise) => {
console.log(promise);
return promise();
});
the messages arrive in random order, but the console.log(promise)
returns the API calls in order? How can I sequentially send, using the Bluebird library, messages to the Messenger Send API?