Let’s add the required constants to the file
DELETE_WORD - the value of all constants is equal to their name.
Export two more functions from
Each must return an object with fields
type field is equal to the constants
payload equals a single argument to each function, respectively.
In the same place we will add a request method
fetchWord with three arguments: the word to search for,
listKey and the object
This method must return an asynchronous function with one
First dispatch the action for the
loading field with the value
Then we make a request using fetch, the url of which is obtained from the
If the answer is no error, dispatch the addWord action with the result of the response and
setError with the argument
null and call the method
If the response is an error, dispatch the
setError action with this error.
setLoading with the value
false at the end.
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.