url-status-code

Get status code for url

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
url-status-code
552.0.04 years ago8 years agoMinified + gzip package size for url-status-code in KB

Readme

Build Status Coverage Status js-standard-style
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

License

MIT