const loadUsers = () => {
return function (dispatch) {
axios
.get(`${process.env.REACT_APP_API}`)
.then((resp) => {
console.log(resp);
dispatch(getUsers(resp.data));
})
.catch((error) => console.log(error));
};
};
I'm getting this error in the above code.
If an arrow function's block only has one return statement, you can omit the block and the return keyword. According to the linter you're using, you need to indeed do that:
const loadUsers = () => function (dispatch) {
axios
.get(`${process.env.REACT_APP_API}`)
.then((resp) => {
console.log(resp);
dispatch(getUsers(resp.data));
})
.catch((error) => console.log(error));
};