T
T
tostera2020-04-15 13:26:03
JavaScript
tostera, 2020-04-15 13:26:03

How to make the response sent after actions?

I want the response to be sent after all the code is done. Can this be done?

app.post('/', async function(req, res) { 
  ... //код
  res.send("ok")
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mopsicus, 2020-04-15
@mopsicus

Read about async / await and all questions will disappear. It's simple there.
https://learn.javascript.ru/async-await

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question