Code Monkey home page Code Monkey logo

Comments (5)

daffl avatar daffl commented on July 22, 2024

Does

app.service('/messages').create({
  text: 'Hello'
}).then(result => {
...
}).catch(error => {
return error.response.json() // Never resolves
}).catch(console.error.bind(console));

log anything? I'm wondering if error.response.json() throws (I'm not sure what it's supposed to do) or something before.

from feathers-rest.

mcchrish avatar mcchrish commented on July 22, 2024

This is the closest I can get at replicating.
https://github.com/mcchrish/feathers-fetch-error
Sorry, it requires a couple of steps:

npm start

Then test by mocha:

mocha test/client.test.js

It pauses at return error.response.json() then mocha will timeout.

from feathers-rest.

daffl avatar daffl commented on July 22, 2024

If you return something in a Promise catch, that promise is no longer rejected. In your example (thank you for uploading) something like

app.service('/messages').create({})
      .catch(error => {
        console.log('!!!!', error.message);
        throw error;
      })

Works as expected. If you make sure that you have the latest version of feathers-rest installed (the one that includes #53) the error will also be converted properly to a Feathers error and there shouldn't be a reason for calling error.response.json().

from feathers-rest.

mcchrish avatar mcchrish commented on July 22, 2024

Oh, so that's what changed.
Using 1.4.* currently, while reverting 1.3.0 makes my code works.
That's why there is no need for error.response.json() anymore, which is pretty neat.

Thanks 👍

from feathers-rest.

daffl avatar daffl commented on July 22, 2024

Ah sorry, I didn't think it would be a breaking change since the REST error handling (especially for fetch and jQuery) was kind of broken before but obviously it needed to be worked around then. Glad we figured it out and hopefully this fix will make things easier.

from feathers-rest.

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.