Git Product home page Git Product logo

Comments (6)

bbirand avatar bbirand commented on May 14, 2024

I see now that this is the place where the magic happens:

const json = response.json() // TODO: support other response types

If you can point me in the right direction, I can try to give this a shot.

from react-refetch.

hnordt avatar hnordt commented on May 14, 2024

I would like to suggest something like this:

connect(({ name }) => ({
  barFetch: {
    url: `/foos/${name}.csv`,
    dataType: 'csv' // maybe responseType?
  }
}))

@ryanbrainard,

If approve this I would like to pull request.

from react-refetch.

ryanbrainard avatar ryanbrainard commented on May 14, 2024

I'm all for accepting more than just JSON, but I'd kind of like to have it based on the Content-Type header in the response rather than adding a new attribute. That might be wishful thinking since there's always going to be some API that doesn't have the right headers and anyway clients will need to send the Accept header as well.

Another idea is to have customizable response processors. This is kind of possible now with PromiseState.then(), but since it's defaulting to JSON, it's too late once it gets to then().

So, given all this, I'm thinking we should use the response Content-Type if we can, fall through to JSON for backward compatibility, and allow it to be overridden by an attribute. Thoughts?

from react-refetch.

hnordt avatar hnordt commented on May 14, 2024

@ryanbrainard 👍 for Content-Type.

Please look at my enhancers idea: #9 (comment)

from react-refetch.

hnordt avatar hnordt commented on May 14, 2024

@ryanbrainard my suggestion on #40 (comment) can handle this

from react-refetch.

ryanbrainard avatar ryanbrainard commented on May 14, 2024

v1.0.0-beta.0 has the ability to change the buildRequest, fetch, and handle Response implementations, which should open up a lot of possibilities here. These features are probably a little too low level for everyday post-processing; however, I want people to kick the tires on them and see what can possibly be built on top of them. I'm going to close this issue now so that we can re-frame remaining enhancements in this new context by opening new issues.

from react-refetch.

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.