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 axios from 'axios';
import config from '../configs'; import config from '../configs';
import store from "../redux/store"; import { store } from "../redux/store";
const apiLogRequest = (apiName: any, axiosRequest: any) => { const apiLogRequest = (apiName: any, axiosRequest: any) => {
console.group && console.group &&
...@@ -58,7 +58,7 @@ const client = axios.create({ ...@@ -58,7 +58,7 @@ const client = axios.create({
client.interceptors.request.use( client.interceptors.request.use(
request => { request => {
const token = store.getState().auth.token; const token = store.getState().auth
request.headers.Authorization = token; request.headers.Authorization = token;
return request; return request;
} }
......
...@@ -2,7 +2,9 @@ import axios from 'axios' ...@@ -2,7 +2,9 @@ import axios from 'axios'
import config from '../configs' import config from '../configs'
import { store } from '../redux/store' import { store } from '../redux/store'
export function* getListProducts() {
const token = store.getState().auth.token
export function getListProducts() {
const body = { const body = {
"drug_barcode": "", "drug_barcode": "",
......
...@@ -18,36 +18,6 @@ const initialState : InitStateAuth = { ...@@ -18,36 +18,6 @@ const initialState : InitStateAuth = {
token: null 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) { function productReducer(state = initialState, action: ActionType) {
const payload = action.payload const payload = action.payload
...@@ -55,7 +25,7 @@ function productReducer(state = initialState, action: ActionType) { ...@@ -55,7 +25,7 @@ function productReducer(state = initialState, action: ActionType) {
case 'LOGIN_SUCCESS': case 'LOGIN_SUCCESS':
return { return {
...state, ...state,
token: payload, auth: payload,
}; };
default: default:
return state 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