state.loading = false;
state.access_token = action.payload.access_token;
state.refresh_token = action.payload.refresh_token;
},
[loginAction.pending.type]: state => {
state.loading = true;
},
[loginAction.rejected.type]: state => {
state.loading = false;
},
export const loginAction = createAsyncThunk<
ILogin,
{
data: ILogin;
onSuccess?: (response: ILogin) => void;
onError?: (e: any) => void;
}
>('auth', async arg => {
try {
const {data: response} = await apiClient.post<ILogin>(
R.consts.API_PATH_LOGIN,
{
...arg.data,
accessToken: arg.data.access_token,
refresh_token: arg.data.refresh_token,
},
);
arg.onSuccess?.(response);
return response;
} catch (e: any) {
arg.onError?.(e.response);
throw e;
}
});
payload не приходит, что не так?
Обсуждают сегодня