Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Get The HTTP Status Code Of A Web Page

HTTP and HTTPS are called via different modules

Code

const https = require('https')

https.get('https://www.alanwsmith.com/', (res) => {
  console.log('statusCode:', res.statusCode)
  console.log('headers:', res.headers)
})

Code

const http = require('http')

http.get('http://www.alanwsmith.com/', (res) => {
  console.log('statusCode:', res.statusCode)
  console.log('headers:', res.headers)
})