A little out of my wheelhouse with Node, but I’m getting there… working on an integration through AWS.
This set of Promises time out if I set to less than 5 seconds. Am I structuring it improperly or is that the kind of response I should prepare myself for? Perhaps I’m not structuring the fnPr
call properly?
I’d like to call the function and go, but I need some kind of feedback… the Particle device did recieve the function call… I’ll eventually add a handler for a bad return.
Testing: I am using only three devices in the capturedDevices
array…
}).then(function(){
//console.log(capturedDevices); // tested OK
capturedDevices.forEach(function(value){
//console.log(value); // tested OK
return Promise.all(capturedDevices.map(function(value){
return new Promise (function(resolve, reject){
var fnPr = particle.callFunction({ deviceId: value, name: 'SetColor', argument: 'rgb(0,255,0)', auth: accessToken });
fnPr.then(function(error, data) {
if(error){
reject(error);
}else{
console.log(data); // I'm not seeing this return on the console?
resolve(data);
}
});
});
}));
});
}).then(function(){
console.log("done"); // tested OK
})
.catch(function(err){
console.log("error message:" + error); // need to test...
});