使用Bluebird Promise.each了解顺序Promise

时间:2018-01-23 18:05:46

标签: javascript bluebird facebook-messenger facebook-send-api

我希望按顺序(按给定数组的顺序)向Messenger Send API发送一组消息。

当我发送两条消息时,如下:

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();
});

邮件按随机顺序到达,但 console.log(promise)按顺序返回API调用?如何使用Bluebird库按顺序将消息发送到Messenger Send API?

0 个答案:

没有答案