Commit 33db63cc authored by Nguyen Danh Khanh's avatar Nguyen Danh Khanh

fixApi

parent 4ab396ac
Pipeline #156 failed with stages
import axios from 'axios';
import config from '../configs';
import store from "../redux/store";
import { store } from "../redux/store";
const apiLogRequest = (apiName: any, axiosRequest: any) => {
console.group &&
......@@ -58,7 +58,7 @@ const client = axios.create({
client.interceptors.request.use(
request => {
const token = store.getState().auth.token;
const token = store.getState().auth
request.headers.Authorization = token;
return request;
}
......
......@@ -2,7 +2,9 @@ import axios from 'axios'
import config from '../configs'
import { store } from '../redux/store'
export function* getListProducts() {
const token = store.getState().auth.token
export function getListProducts() {
const body = {
"drug_barcode": "",
......
......@@ -18,36 +18,6 @@ const initialState : InitStateAuth = {
token: null
}
// const auth = createSlice({
// name: 'auth',
// initialState,
// reducers: {
// loginSuccess(state, action) {
// state.token = action.payload.token
// }
// }
// })
// const { loginSuccess } = auth.actions
interface CounterState {
username: string
password: string
token: string | null
}
// const authReducer = (state = initialState, action: AnyAction) => {
// const { type, payload } = action;
// switch (type) {
// case Types.LOGIN: {
// return {
// ...state,
// isLogin: payload,
// };
// }
// default:
// return state;
// }
// }
function productReducer(state = initialState, action: ActionType) {
const payload = action.payload
......@@ -55,7 +25,7 @@ function productReducer(state = initialState, action: ActionType) {
case 'LOGIN_SUCCESS':
return {
...state,
token: payload,
auth: payload,
};
default:
return state
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment