How can I send a success status to browser from nodejs/express?
In express 4 you should do:
res.status(200).json({status:"ok"})
instead of the deprecated:
res.json(200,{status:"ok"})
Just wanted to add, that you can send json via the res.json()
helper.
res.json({ok:true}); // status 200 is default
res.json(500, {error:"internal server error"}); // status 500
Update 2015:
res.json(status, obj)
has been deprecated in favor of res.status(status).json(obj)
res.status(500).json({error: "Internal server error"});
Express Update 2015:
Use this instead:
res.sendStatus(200)
This has been deprecated:
res.send(200)