Giter Site home page Giter Site logo

Comments (5)

mdlavin avatar mdlavin commented on May 24, 2024 1

The simplest thing I can think of that might work is to change:

} catch (err) {
  result = err.response;
}

into

} catch (err) {
  // Non-HTTP failures should be re-thrown. This will handle lower level network failures
  if (!err.response) throw err;
  // HTTP level failures can be translated into fetch style responses
  result = err.response;
}

Is it possible for you to try a change like that and see if it fixes your problem?

from axios-fetch.

mdlavin avatar mdlavin commented on May 24, 2024

That's a case I haven't thought of before. This project is based around having axios-fetch behave just like fetch does, so my first question is "How does fetch behave in the offline case?".

If you know that, I have a feeling that the code here could be updated to match the fetch behavior if .response is missing

from axios-fetch.

troym9731 avatar troym9731 commented on May 24, 2024

So it seems like it fails with a TypeError, and is one of the few cases that fetch returns a rejected promise.

Here is a post I found detailing the different error messages based on the browser: https://medium.com/vinh-rocks/how-to-handle-networkerror-when-using-fetch-ff2663220435

And here is the line of a test case in node-fetch for handling a network failure: https://github.com/node-fetch/node-fetch/blob/master/test/main.js#L110

So what would be your preferred path forward?

from axios-fetch.

troym9731 avatar troym9731 commented on May 24, 2024

That appears to work! Would you like me to open a PR with those changes, or would it be simpler for you to just commit the change yourself?

from axios-fetch.

jkdowdle avatar jkdowdle commented on May 24, 2024

Unless someone feels otherwise going to go ahead and close this issue. The proposed solution was implemented in #78 and released in @lifeomic/[email protected] #79

from axios-fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.