Created
November 3, 2017 02:42
-
-
Save pngmark/31f2298ee6ea27831cb1e9864fc7b047 to your computer and use it in GitHub Desktop.
HTTP status codes for JavaScript array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var statusMessages = [ | |
'200': 'OK', | |
'201': 'Created', | |
'200': 'OK', | |
'201': 'Created', | |
'202': 'Accepted', | |
'203': 'Non-Authoritative Information', | |
'204': 'No Content', | |
'205': 'Reset Content', | |
'206': 'Partial Content', | |
'207': 'Multi-Status (WebDAV)', | |
'208': 'Already Reported (WebDAV)', | |
'226': 'IM Used', | |
'300': 'Multiple Choices', | |
'301': 'Moved Permanently', | |
'302': 'Found', | |
'303': 'See Other', | |
'304': 'Not Modified', | |
'305': 'Use Proxy', | |
'306': '(Unused)', | |
'307': 'Temporary Redirect', | |
'308': 'Permanent Redirect (experimental)', | |
'400': 'Bad Request', | |
'401': 'Unauthorized', | |
'402': 'Payment Required', | |
'403': 'Forbidden', | |
'404': 'Not Found', | |
'405': 'Method Not Allowed', | |
'406': 'Not Acceptable', | |
'407': 'Proxy Authentication Required', | |
'408': 'Request Timeout', | |
'409': 'Conflict', | |
'410': 'Gone', | |
'411': 'Length Required', | |
'412': 'Precondition Failed', | |
'413': 'Request Entity Too Large', | |
'414': 'Request-URI Too Long', | |
'415': 'Unsupported Media Type', | |
'416': 'Requested Range Not Satisfiable', | |
'417': 'Expectation Failed', | |
'418': 'I'm a teapot (RFC 2324)', | |
'420': 'Enhance Your Calm (Twitter)', | |
'422': 'Unprocessable Entity (WebDAV)', | |
'423': 'Locked (WebDAV)', | |
'424': 'Failed Dependency (WebDAV)', | |
'425': 'Reserved for WebDAV', | |
'426': 'Upgrade Required', | |
'428': 'Precondition Required', | |
'429': 'Too Many Requests', | |
'431': 'Request Header Fields Too Large', | |
'444': 'No Response (Nginx)', | |
'449': 'Retry With (Microsoft)', | |
'450': 'Blocked by Windows Parental Controls (Microsoft)', | |
'451': 'Unavailable For Legal Reasons', | |
'499': 'Client Closed Request (Nginx)', | |
'500': 'Internal Server Error', | |
'501': 'Not Implemented', | |
'502': 'Bad Gateway', | |
'503': 'Service Unavailable', | |
'504': 'Gateway Timeout', | |
'505': 'HTTP Version Not Supported', | |
'506': 'Variant Also Negotiates (Experimental)', | |
'507': 'Insufficient Storage (WebDAV)', | |
'508': 'Loop Detected (WebDAV)', | |
'509': 'Bandwidth Limit Exceeded (Apache)', | |
'510': 'Not Extended', | |
'511': 'Network Authentication Required', | |
'598': 'Network read timeout error', | |
'599': 'Network connect timeout error', ' | |
]; |
I'm feeling unexpected token :
There are a few errors with this code indeed. Thankfully, the fix is to just replace the []
with {}
, and remove the trailing apostrophe in the second last line. You'll also have to add a backslash (\
) before the unescaped apostrophe in the value of status code 418 to fix another error too. This data was probably scraped off a webpage and that's why there are these errors. And, for some reason, the two keys/values are duplicates so remove one of the pairs.
I've made an object array version tho and added some more codes that I knew.
const possibleHTTPArray = [
{ status: '200', message: 'OK' },
{ status: '201', message: 'Created' },
{ status: '202', message: 'Accepted' },
{ status: '203', message: 'Non-Authoritative Information' },
{ status: '204', message: 'No Content' },
{ status: '205', message: 'Reset Content' },
{ status: '206', message: 'Partial Content' },
{ status: '207', message: 'Multi-Status' },
{ status: '208', message: 'Already Reported (WebDAV)' },
{ status: '226', message: 'IM Used' },
{ status: '300', message: 'Multiple Choices' },
{ status: '301', message: 'Moved Permanently' },
{ status: '302', message: 'Found' },
{ status: '303', message: 'See Other' },
{ status: '304', message: 'Not Modified' },
{ status: '305', message: 'Use Proxy' },
{ status: '307', message: 'Temporary Redirect' },
{ status: '308', message: 'Permanent Redirect' },
{ status: '400', message: 'Bad Request' },
{ status: '401', message: 'Unauthorized' },
{ status: '402', message: 'Payment Required' },
{ status: '403', message: 'Forbidden' },
{ status: '404', message: 'Not Found' },
{ status: '405', message: 'Method Not Allowed' },
{ status: '406', message: 'Not Acceptable' },
{ status: '407', message: 'Proxy Authentication Required' },
{ status: '408', message: 'Request Timeout' },
{ status: '409', message: 'Conflict' },
{ status: '410', message: 'Gone' },
{ status: '411', message: 'Length Required' },
{ status: '412', message: 'Precondition Failed' },
{ status: '413', message: 'Request Entity Too Large' },
{ status: '414', message: 'Request-URI Too Long' },
{ status: '415', message: 'Unsupported Media Type' },
{ status: '416', message: 'Requested Range Not Satisfiable' },
{ status: '417', message: 'Expectation Failed' },
{ status: '418', message: `I'm a teapot` },
{ status: '420', message: 'Enhance Your Calm' },
{ status: '421', message: 'Misdirected Request' },
{ status: '422', message: 'Unprocessable Entity' },
{ status: '423', message: 'Locked' },
{ status: '424', message: 'Failed Dependency' },
{ status: '425', message: 'Too Early' },
{ status: '426', message: 'Upgrade Required' },
{ status: '428', message: 'Precondition Required' },
{ status: '429', message: 'Too Many Requests' },
{ status: '431', message: 'Request Header Fields Too Large' },
{ status: '444', message: 'No Response' },
{ status: '449', message: 'Retry With' },
{ status: '450', message: 'Blocked by Windows Parental Controls' },
{ status: '451', message: 'Unavailable For Legal Reasons' },
{ status: '497', message: 'HTTP Request Sent to HTTPS Port' },
{ status: '498', message: 'Token expired/invalid' },
{ status: '499', message: 'Client Closed Request' },
{ status: '500', message: 'Internal Server Error' },
{ status: '501', message: 'Not Implemented' },
{ status: '502', message: 'Bad Gateway' },
{ status: '503', message: 'Service Unavailable' },
{ status: '504', message: 'Gateway Timeout' },
{ status: '505', message: 'HTTP Version Not Supported' },
{ status: '506', message: 'Variant Also Negotiates' },
{ status: '507', message: 'Insufficient Storage' },
{ status: '508', message: 'Loop Detected' },
{ status: '509', message: 'Bandwidth Limit Exceeded' },
{ status: '510', message: 'Not Extended' },
{ status: '511', message: 'Network Authentication Required' },
{ status: '521', message: 'Web Server is Down' },
{ status: '523', message: 'Origin is Unreachable' },
{ status: '525', message: 'SSL Handshake Failed' },
{ status: '598', message: 'Network read timeout error' },
{ status: '599', message: 'Network connect timeout error' },
];
@ViniciusResende Duplicated 502, missing 503
Thank you @ViniciusResende
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is this an array or an object? 🤔