V
V
Vadim Remin2015-11-18 21:49:29
JavaScript
Vadim Remin, 2015-11-18 21:49:29

NODE.js and Express: how to bind an async call to receive a POST request. functions and executing res.end() only on an event?

Good afternoon,
there is node.js with express. You need to do the following

app.post("/", function(){
    AsyncFoo();
      myEventEmitter.on("AsyncFoo done", function(){
        res.end();
      });
  })

The problem is that a new Node Event Loop pass for the second request to the server does not start. process.nextTick() only runs once. How to untie them? When requested, the user uploads the file, and AsyncFoo() processes it asynchronously.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Lyzlov, 2015-11-18
@dkudrin1

Duck pass a callback to AsyncFoo and call res.end there, why are there events?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question