Fetch data by Redux from browser
See original GitHub issueGood day! How can I use fetch in Redux action? I use fetch from context in React component like this:
static contextTypes = {
fetch: PropTypes.func.isRequired,
};
...
async getData {
const URL = '/api/search/content';
const res = await this.context.fetch(URL);
const {data} = await res.json();
...
}
...
<button onClick={this.getData.bind(this)}/>
And now I want to do fetch in Redux action, and my question is how can I use this.context.fetch
in Redux action
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Redux Essentials, Part 5: Async Logic and Data Fetching
The official Redux Essentials tutorial: learn how async logic works in Redux apps.
Read more >Data fetching with Redux and Axios - LogRocket Blog
Learn how to use Redux and a library like Axios to turn data fetching and state management from a nightmare to a breeze....
Read more >Redux Toolkit Tutorial - 30 - Fetching Data - YouTube
Your browser can't play this video. ... Business - codevolution.business@gmail.com Fetching Data with React and Redux Redux Toolkit Tutorial ...
Read more >Fetching data in Redux using RTK Query - OpenReplay Blog
Along with using Redux for state management, you can now also fetch and cached data with ease without using React Query, SWR, ...
Read more >Data fetching in Redux is painful, get rid of it now - Medium
Fetching data in Redux is a quite verbose process. Each fetch operation requires the developer to create: ... Writing all this code takes...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also missed pointing out the other error I was making. The
return async
takes in 3 parameters, the third parameter contains the fetch function. Like below.There is fetch helper injected to redux-thunk actions