0๐
//-------------in login.js---------------------
import request from 'path here'
const userAccountLogin = ({ account, password }) => {
return request('/login', 'post', { account, password })
}
// ----------in request.js--------------------
import axios from 'axios'
const baseURL = 'http://apiserver.net/'
const instance = axios.create({
baseURL,
timeout: 5000
})
export default (url, method, submitData) => {
return instance({
url,
method,
[method.toLowerCase() === 'get' ? 'params' : 'data']: submitData
})
}
Source:stackexchange.com