How can I send a success status to browser from nodejs/express?

前端 未结 4 1417
南笙
南笙 2021-02-02 05:13

I\'ve written the following piece of code in my nodeJS/Expressjs server:

app.post(\'/settings\', function(req, res){
    var myData = {
        a: req.param(\'a\         


        
4条回答
  •  广开言路
    2021-02-02 05:45

    Jup, you need to send an answer back, the simplest would be

    res.send(200);
    

    Inside the callback handler of writeFile.

    The 200 is a HTTP status code, so you could even vary that in case of failure:

    if (err) {
        res.send(500);
    } else {
        res.send(200);
    }
    

提交回复
热议问题