Questions tagged [redux-async-actions]
12 questions
5
votes
1 answer
How I send custom parameters on `createAsyncThunk` on "pending" status?
When fetchUserById() is created its output response is defined.
const fetchUserById = createAsyncThunk<{user: UserInterface, id: number}, number>(
'users/fetchByIdStatus',
async (userId) => {
const response = await userAPI.fetchById(userId)
…

Jose Enrique Marquez
- 95
- 1
- 6
2
votes
1 answer
Using getState in redux-thunk async action
I'm trying to use getState function in async action. I'm working in React with Typescript and middleware redux-thunk. I've added argument with getState as a second argument like below:
export const fetchPostsAndUsers = () => async (
dispatch:…

Krzysztof Michalski
- 791
- 1
- 9
- 25
2
votes
1 answer
Testing redux async actions with Typescript
Hey guys I am trying to test my async actions creators with Typescript but I am getting a type error that I cannot manage to solve.
This is my actions:
export const loadCurrentUserRequest = () => ({
type: LOAD_CURRENT_USER_REQUEST
})
export…

SuperMarco
- 710
- 12
- 31
1
vote
1 answer
AXIOS POST ERROR: "http://loclhost:5001/cartdata net::ERR_NAME_NOT_RESOLVED"
I faced problem when I tried to connect my react-redux(redux thunk) project with my backend. I tried to post product_id and the quantity(qty) to my backend server. I checked server using Postman. It works properly. But from frontend, I got this…

Samrat Alam
- 558
- 3
- 19
1
vote
2 answers
Redux store get empty in component
I have a problem with getting the redux store in my component. I am using redux-react async to fetch data from api. I got the data from jsonplaceholder api, however I have a problem configuring the store and connecting the store with the root…

Daniel Nilles
- 41
- 2
- 8
0
votes
1 answer
Redux - updating store based on async api calls
I have a use case to render page using redux with graphql api calls.
On first component will call default action to fetch data from graphql, and stores in redux state as below
state = { films: {
totalCount: 6,
films: [
…

sudpap
- 3
- 2
0
votes
1 answer
How to perform dependent async calls in redux?
Background
I am having react application which uses redux and redux-thunk.
Trying to understand how to orchestrate async calls. How to dispatch actions only if previously dispatched action (API call) was successul.
Use Case
I have…

Hola
- 329
- 3
- 18
0
votes
0 answers
What is the best practice for using Redux to handle full async services?
I wonder what is the best way to handle an async service using Redux with error, loading, ... and how to implement that?
I am currently using Promise an axios to handle API and call
3 actions request, success and failure:
export function…

Neil Nguyen
- 349
- 2
- 7
0
votes
0 answers
React-redux action is called endlessly(infinite loop)
The react-component is re-rendering endlessly when action is called inside an useEffect function
useEffect(() => {
props.getApi('pages/websitepage/page_type/choices')
},[])
Here i am using connect method for dispatching the action(also…

gautam siva
- 103
- 2
- 11
0
votes
1 answer
Jest async action creators:TypeError: Cannot read property 'then' of undefined
Kinda newbie to jest here.I am trying to write unit test cases for one of the async action creators in my React project using jest. I keep running into the error TypeError: Cannot read property 'then' of undefined
Below is my action creator:
import…

Geethu Ann Joseph
- 109
- 1
- 12
0
votes
1 answer
C# TestMethod - async Index()
I am new to Unit Testing and relatively new to C# too. Not a great combination! I have looked at similar questions on this forum and tried solutions with no success.
Within my Home Controller, I have defined the following method. How do I write a…

PhilSmith
- 1
- 2
0
votes
1 answer
Data is lost somewhere in action wiring
I have a simple registration form with fields for email, password, and admin code. I am passing this data into my action creator and I have it passing through three actions before finishing up the registration. Somewhere in there, it is just…

drkgrntt
- 25
- 1
- 8