Comments (5)
Interesting point. I've always used manual
and issued the request myself using fetch
for POST
calls. Since POST
calls are more risky (changing data, etc) I've always assumed others would be doing the same.
We could look into supporting a way to trigger an automatic refetch based on other parameters (body, but not necessarily limited to it, for example changing headers, etc).
In your case is it possible to issue the request manually, or does it need to be automatic (and the url
fragment is a decent workaround like you found)?
from react-fetch-component.
Yea, I admit that this is a bit of an odd usecase; the API we're calling is doing an analytic query, so it's not actually modifying state, but it may require a lot of input params that are better suited to a body and the query isn't computationally cheap, so it's a POST (I also didn't design the API we're calling, so I don't have much control over the decision :P)
Yea, while options.body
is my particular usecase, a more generic solution makes sense to me.
Yea, there are plenty of workarounds. We could use manual
, or just keep doing the url fragment thing, so this isn't super urgent. It was mostly just not intuitive to change the body and have it not refetch and not know why without digging into source code.
from react-fetch-component.
@ncknuna I added support for this use case with a new deps
(aka depenencies) prop.
I use this on new GraphQL component I'm working on where you always POST to the /graphql
endpoint with a different body (query/variables). So far it's working well (and plan to open source it once I've settled on the API. Plan is to keep it lightweight (much more so than apollo-client, etc). It's based on react-fetch-component
similar to how my react-odata
one was.
I need to update the docs to show deps
, but take a look at the commit and tests.
from react-fetch-component.
@ncknuna Forgot to mention this is in v8.0.0-9
prerelease. Just waiting for Hooks to be released (maybe Feb 4th) to make it 8.0
stable.
from react-fetch-component.
Ah, cool, thanks :D
from react-fetch-component.
Related Issues (20)
- Research running fetch in a webworker
- Supply caching strategy
- Add FetchMock
- error remains an empty object HOT 1
- Only retain successful responses in cache HOT 8
- Support aborting HOT 1
- Do not call setState when component is unmounted
- `loading` initially starts as `null`? HOT 6
- Allow for fetching cached data HOT 3
- Add support for Hooks HOT 1
- Use Typescript
- Support Suspense
- How to refetch data if error occured HOT 3
- Uncaught (in promise) TypeError: failed to fetch HOT 1
- Is this project abandoned? HOT 2
- Add explicit "onDataChange" property
- [Feature] Debounce requests HOT 2
- Support async onDataChange HOT 1
- Smart body parsing based on Content-Type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-fetch-component.