Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Get Redirect Status Code From node - fetch

By default, node - fetch follows redirects and will return a 200 if the target page exists.

To get the status of the original page, set the [TODO: Code shorthand span ] option to ` manual ` . For example :

javascript
const fetch = require('node-fetch')

fetch('https://www.alanwsmith.com/first-post-yeah-yeah', {
  redirect: 'manual',
}).then((res) => {
  console.log(res.status)
})

Returns ` 301 `

If you want to see the status code of the final page after processing redirects, remove the option