Skip to content
Advertisement

React Redux createAsyncThunk actions don’t update the state

I’m implementing a registration page to my nodejs api. With createAsyncThunk I implemented the function to fetch the user data and update the state. The api works correctly, in fact it returns the created user data in the payload when the action is dispatched. But the user state is not updated and stays the initial state.

Here the user slice code:

JavaScript

The store.js:

JavaScript

The registration page:

JavaScript

here an image of the console

Advertisement

Answer

I modified the request field in this way:

JavaScript

And instead of writing fulfilled I had written fullFilled

Old code:

JavaScript

New code:

JavaScript

And now it works

Advertisement