Giter VIP home page Giter VIP logo

Comments (5)

tomtomau avatar tomtomau commented on July 23, 2024 1

Hmm, okay. I've fixed up the cert and it is working but when I substitute my own API I still had the issues.

For now, I think the issue lies in that my API is not returning Access-Control-Allow-Origin: * on the header, thus it turns into a network request.

For future people who hit this issue - check your headers on the Response.

Thank you @bryanrsmith

from fetch-client.

bryanrsmith avatar bryanrsmith commented on July 23, 2024 1

No problem! For error responses you should see the status code in dev tools, and you should see a Response instance in the interceptor or continuation. If you see a TypeError or other JS error type there's probably another issue.

One other thing I noticed-- your requestError interceptor is returning the Response instead of throwing it. That will cause the Promise returned by HttpClient.prototype.fetch() to resolve successfully instead of rejecting. Unless your interceptor is recovering from the error you typically will want to rethrow the unsuccessful Response (or use return Promise.reject(response)).

from fetch-client.

bryanrsmith avatar bryanrsmith commented on July 23, 2024

The httpstat.us service you're using to generate the 500 response appears to have an invalid SSL cert, so the browser is rejecting the request with a TypeError. If you visit the site using https in your browser and tell Chrome to accept the cert then the gist runs as expected.

from fetch-client.

tomtomau avatar tomtomau commented on July 23, 2024

Hi @bryanrsmith,
Thanks for replying to this issue. The same issue exists when you substitute for an API that returns a 500. I replaced the URL with our API that I know returns a 500 and I still cannot access the status key.

from fetch-client.

bryanrsmith avatar bryanrsmith commented on July 23, 2024

What output do you expect to see? Here's what I see, which is what I would expect from the code:

image

from fetch-client.

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.