Hi guys,
I am trying to develop a little node which is asynchronously calling an endpoint.
And in my node I have this function, where getStationStatus
return a promise:
node.on('input', function(msg, send, done) {
send = send || function() { node.send.apply(node,arguments) }
msg.payload = "data-before-call";
const stationService = require('./services/station_service');
stationService.getStationStatus(node.stationID).then(
result => {
//msg.payload = result;
console.log(result.goalId);
name = result.name;
msg.payload.goalId = result.goalId;
msg.payload.name = result.name;
send(msg);
node.log("msg sent");
node.log(msg);
done();
},
error => {
console.log(error);
msg.payload = error;
done(error);
}
);
});
The service is called correctly and I also see the logs from node.log(msg);
which have the correct data.
But if I add a debug Node after this node, the debug node only prints data-before-call
as if send(msg)
has no effect.
I don't know what's wrong here.
In my oppinion I am doing what is suggested in the documentation.