Is there a way of converting numeric http status codes (i.e. 404,403,500,...) to their display names (Not Found, Forbidden, Internal Server Error,...) ?
If it helps anything, I am using AngularJS and jQuery.
You could construct your own object (or download this one) and look them up there:
var codes = {
"100": "Continue",
"101": "Switching Protocols",
"102": "Processing",
"200": "OK",
...
};
var code = 200;
console.log(codes[code]); // "Ok"
You can use http-status-codes from npm.
var HttpStatus = require('http-status-codes');
HttpStatus.getStatusText(200) // ==> "OK"
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