Skip to content

Redirect on errors #338

@max-degterev

Description

@max-degterev

Hi, not sure if it's a bug or me not using the library properly.

I have this quick demo: https://runkit.com/suprmax/5fc78c9c251bb3001a7d3555

const needle = require('needle');

const url = 'http://www.mein-contipark.de';
let calls = 0;

needle.head(url, { follow_max: 2 }, (...args) => {
  calls += 1;
  console.log(`Call #${calls}`, args);
});

When follow_max prop is set first request fails and also redirects. There is no way that I can see to detect that redirect occured. Then second request succeeds but in my application I already assume request failed. Is there a way to detect these error-y redirects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions