【发布时间】:2020-12-17 21:04:16
【问题描述】:
我正在尝试在我的 API 中使用从这个传奇返回的 Bearer 令牌进行身份验证,并且我想将它传递给 Authorization HTTP 标头,有人知道该怎么做吗?谢谢。
import { takeLatest, call, put, all } from 'redux-saga/effects';
import { apiCore } from '@/services/api';
import { ActionType } from 'typesafe-actions';
import * as actions from './actions';
export function* signIn(action: ActionType<typeof actions.signInRequest>) {
try {
const { email, password } = action.payload;
const { data } = yield call(apiCore.post, '/auth/myapp/login', {
email,
password
});
yield put(actions.signInSuccess({ token: data.result.token }));
**yield call(apiCore.get, '', PASS THE TOKEN SOMEHOW? (data.result.token))????**
} catch (err) {
yield put(actions.signInFailure());
}
}
export default all([takeLatest('@login/SIGN_IN_REQUEST', signIn)]);
【问题讨论】:
标签: reactjs http redux axios redux-saga