3 ms·
fs.readFile("person.json") .then(function(e, personJson) { var person = JSON.parse(personJson); return myDB.query("lastname", person.name);
by TheZenPsycho 13y ago
fs.readFile("person.json")
.then(function(e, personJson) {
var person = JSON.parse(personJson);
return myDB.query("lastname", person.name);
})
.then(function(matched) {
return msgQueue.push(JSON.stringify(matchesLastname));
})
.then(function(id) {
log.info("Message sent to queue: " + id);
});
- ilaksh 13y agoThat's part of it. What about creating the promises?
- TheZenPsycho 13y agothat's in there, with the assumption that you're using the promises based node.js api, but if you aren't, and you're using Q, that part looks like this var readFile = Q.denodeify(FS.readFile); which doesn't create the promise. it just wraps the readFile method so that it returns a promise when you call it.