Let’s work on the redux methods. But first, let’s add the required constants to the src/external/redux/constants
file.
API
, FETCH_WORD_ENDPOINT
, ADD_WORD
, SET_ERROR
, SET_LOADING
- the value of all constants is equal to their name.
And then add the export of the getFetchWordEndpoint
function to the src/external/redux/helpers
file.
This function must take one argument - the word to search for.
It will return the request url, which consists of API
and FETCH_WORD_ENDPOINT
constants.
These two variables need to add a get parameter s
equal to the function argument
Export three more functions from src/external/redux/actions
: addWord
, setError
and setLoading
.
Each must return an object with fields type
and payload
.
The type
field is equal to the constants ADD_WORD
, SET_ERROR
and SET_LOADING
, respectively.
For the setError
and setLoading
functions, payload
equals the single argument of each function, respectively.
The addWord
function has payload
all fields of the first argument, padded with the listKey
field, equal to the second argument of the function.
This task is part of the Full-Stack JavaScript Course.
If you have any issues with it, you can ask for community help below the post.
Feel free to help others if you’ve already solved the task.