check_status_code
v2.0.3
Published
- The http-status-codes package simplifies working with HTTP status codes in Node.js applications. It provides an easy-to-use mapping of common HTTP status codes to their corresponding messages, making it effortless for developers to convey response statu
Downloads
2
Readme
Status code check:
- The http-status-codes package simplifies working with HTTP status codes in Node.js applications. It provides an easy-to-use mapping of common HTTP status codes to their corresponding messages, making it effortless for developers to convey response statuses in their applications.
Installation:
npm i status_code
Code example:
const status_code=require('status_code'); console.log(status_code[200])
Code example2:
const axios = require('axios');
const status_code = require('status_code');
const URL = 'https://jsonplaceholder.typicode.com/posts/1'; // Example URL
axios.get(URL)
.then(response => {
const statusCode = response.status;
const statusMeaning = status_code[statusCode] || 'Unknown';
console.log(`Status Code: ${statusCode}`);
console.log(`Status Meaning: ${statusMeaning}`);
console.log('Response Data:', response.data);
})
.catch(error => {
console.error('Error:', error);
});