I'm running into a callback hell as my project progresses. I want to refractor all my code into using promises. Does anyone know how I can make multiple queries with promise? Especially when the subsequent queries relies on data of previous queries.Example of what I have now.client.query('SELECT * FROM users', function(err, result) { client.query('SELECT * FROM posts WHERE user_id = $1', [result.rows[0].user_id], function(err, result) { // do stuff }); });
Submitted July 04, 2018 at 07:30PM by eggtart_prince
No comments:
Post a Comment