Funny you ask -
I was just asked this by a colleague.
What's needed here is a File node that's not a "sink" node (one input, no output nodes).
One possibility for this is to use the node.js "fs" write function, from within a function node.
Add this to your settings.js (or equivalent) file:
fs:require('fs'),
And then put this in in a function node:
context.global.fs.writeFile('data.json', JSON.stringify(msg.payload), function (err) {
if (err) {
console.log(err);
msg.payload = false
}
else {
console.log('wrote data.json');
msg.payload = true;
}
});
return msg;
The wait for a callback is what makes this have a synchronous wait.
You can do other things like passing in the write location in, e.g., msg.fileURL. And you can change error handling to your preferred alternative (e.g., a separate output for errors).