url-status-code
v2.0.0
Published
Get status code for url
Downloads
6,624
Readme
url-status-code
Get status code for url.
Installation
From npm
$ npm i url-status-code
Usage
(async () => {
const urlStatusCode = require('url-status-code')
const url = 'https://www.npmjs.com'
try {
const status = await urlStatusCode(url)
console.log(status)
} catch (error) {
console.error(error)
}
})()
//=> 200
or you can use callback
const urlStatusCode = require('url-status-code')
const url = 'https://www.npmjs.com'
urlStatusCode(url, (error, statusCode) => {
if (error) {
console.error(error)
} else {
console.log(statusCode)
}
})
// => 200