I've been struggling with this problem for a while now so I figured I'd ask some help.
This is my function:
export function fetchToken(username: String, password: String) {
return async (dispatch: Dispatch) => {
dispatch(fetchTokenStart());
try {
const response = await Axios.post("login", {
username: username,
password: password,
});
dispatch(fetchTokenSucceed(response.data));
} catch (error) {
const response: errorResponse = error as errorResponse;
dispatch(fetchTokenFailure(response.response.data));
}
};
}
And here I try to utilize it:
onClick={() => {
dispatch(fetchToken("username", "password"));
}}
But then, on the fetchToken I get this Typescript error:
TS2345: Argument of type '(dispatch: Dispatch) => Promise<void>' is not assignable to parameter of type 'AnyAction'.