Issue
I'm using a for-loop to send a large text (larger than 320 chars) in multiple messages, but they land in no-particular order:
var arr = ['this', 'is', 'a', 'string'];
for (var i = 0; i < arr.length; i++) {
sendTextMessage(sender, arr[i]);
}
Could land as a, is, this, string
, or any other combination. How do I force them to land in order?
Solution
I assume that you're using the code example from facebook that provides your sendTextMessage method. This one acts asynchronously since it uses request module (https://www.npmjs.com/package/request).
If you want to do synchronous calls - means one after another - you've to use another module, e.g. https://github.com/dhruvbird/http-sync
Answered By - Juergen Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.