Stav Alfi
Stav Alfi

Reputation: 13923

does any call to node js must end with response?

I got a post function to add new user. I dont see any need to return anything to the client. Will the node thread stuck until he find a respond to send back? Is this a good approach?

(I use express)

app.post('/newUser',function(req,res){
        users.push(req.body.user);
    });

Upvotes: 0

Views: 25

Answers (1)

DevAlien
DevAlien

Reputation: 2476

You should always return something to the client. The client waits for a response.

In the case of adding a user, you could return the created user or, if it fails, an error message.

Upvotes: 1

Related Questions