Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  54] [ 4]  / answers: 1 / hits: 47356  / 10 Years ago, fri, august 8, 2014, 12:00:00

I have a long running process which needs to send data back at multiple stages. Is there some way to send back multiple responses with express.js



res.send(200, 'hello')
res.send(200, 'world')
res.end()


but when I run curl -X POST localhost:3001/helloworld all I get is hello



How can I send multiple responses or is this not possible to do with express?


More From » node.js

 Answers
13

Use res.write().



res.send() already makes a call to res.end(), meaning you can't write to res anymore after a call to res.send (meaning also your res.end() call was useless).



EDIT: It is a Node.js internal function. See the documentation here


[#69854] Wednesday, August 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maureen

Total Points: 151
Total Questions: 110
Total Answers: 110

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
maureen questions
Mon, Oct 11, 21, 00:00, 3 Years ago
Wed, Jun 30, 21, 00:00, 3 Years ago
Thu, Apr 15, 21, 00:00, 3 Years ago
Tue, Mar 16, 21, 00:00, 3 Years ago
Mon, Dec 7, 20, 00:00, 4 Years ago
;