如何解决这个Axios拦截器问题?

时间:2019-10-11 11:15:33

标签: reactjs post react-redux axios interceptor

我是Axios拦截器的新手,我无法弄清楚这段代码有什么问题。这是使用Axios Interceptor进行发布请求传递数据(正文)的正确方法吗?

import axios from 'axios';

export const userService = {
    login
};

const axiosInstance = axios.create({
  baseURL: 'https://**********/api/v1'
})

const loginRequestHandler = (request) => {
 request.data['email','password']={email,password} 
  return request
}

axios.interceptors.request.use(
  request => loginRequestHandler(request),
  error =>  Promise.reject(error)
);

 function login(handlerEnabled){
    axiosInstance.post('/auth/local',{handlerEnabled})
}


0 个答案:

没有答案