重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
api/user.js
export const login = ({ userName, password }) => {
const data = {
username: userName,
password
}
return axios.request({
url: '/api/token',
data,
method: 'post'
})
}
config/index.js
baseUrl:
libs/axios.js
import { getToken } from '@/libs/util'
getInsideConfig () {
const config = {
baseURL: this.baseUrl,
headers: {
//
}
}
if (getToken()) {
config.headers['Authorization'] = `token ${getToken()}`
}
return config
}
store/module/user.js
const data = res.data