What is the difference between response.status()and response.sendStatus()in the Express.
response.status()
response.sendStatus()
I notice that it is commonly used for mail, recipient, and other middleware, and is later used in removal requests. Why is this?
status() sets the http status in the response (as a server side javascript object)
status()
sendStatus() both set the status and send it to the client
sendStatus()
http-. sendStatus, , (, HTTP-).
sendStatus
:
https://expressjs.com/en/4x/api.html#res.sendStatus
, sendStatus .
, , status. , JSON, , , ( status), JSON ( send). sendStatus, JSON , .
status
send
Based on the provided @freakish link
res.sendStatus(200); // equivalent to res.status(200).send('OK') res.sendStatus(403); // equivalent to res.status(403).send('Forbidden') res.sendStatus(404); // equivalent to res.status(404).send('Not Found') res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
Source: https://habr.com/ru/post/1649324/More articles:Go to top of page in pdb (python debugger) - pythonWorking with variable length text in Tensorflow - pythonDoctrine find method return Proxies \ ClassProy - repositoryInject service in a simple class constructor with Angular2 - classwindow.customElements undefined in Chrome - javascriptTypeScript: How to extend npm module type definitions? - typescriptCount iterations during a loop - pythonWhat class is inside a non-character library call in R? - rHow to make one string assignment to malloc () arrays in C? - cPandas Expand Minimize - pythonAll Articles