I'm looking for a list of http status codes in Javascript. Are they defined in any implementation?
I've had a look at XMLHttpRequest
, but only found readyState
constants.
var xhr = new XMLHttpRequest(); console.log(xhr.DONE); //4
I'm looking for something like
console.log(xhr.statusCodes.OK); //200
Which obviously doesn't exist on the xhr object.
In the main window of the program, enter your website homepage URL and click on the 'Start' button. As soon as crawling is complete, you will have all status codes in the corresponding table column. Pages with the 4xx and 5xx HTTP status codes will be gathered into special issue reports.
2xx successful – the request was successfully received, understood, and accepted. 3xx redirection – further action needs to be taken in order to complete the request. 4xx client error – the request contains bad syntax or cannot be fulfilled. 5xx server error – the server failed to fulfil an apparently valid request.
The HyperText Transfer Protocol (HTTP) 301 Moved Permanently redirect status response code indicates that the requested resource has been definitively moved to the URL given by the Location headers.
Status codes 309 through 399 are currently unassigned.
For node.js you can use the module node-http-status (github).
This is an example:
var HttpStatus = require('http-status-codes'); response .status(HttpStatus.OK) .send('ok'); response .status(HttpStatus.INTERNAL_SERVER_ERROR) .send({ error: HttpStatus.getStatusText(HttpStatus.INTERNAL_SERVER_ERROR) });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With