You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
const METHOD = {
|
|
|
|
GET: 'get',
|
|
|
|
POST: 'post'
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* axios请求
|
|
|
|
* @param url 请求地址
|
|
|
|
* @param method {METHOD} http method
|
|
|
|
* @param params 请求参数
|
|
|
|
* @returns {Promise<AxiosResponse<T>>}
|
|
|
|
*/
|
|
|
|
async function request(url, method, params) {
|
|
|
|
switch (method) {
|
|
|
|
case METHOD.GET:
|
|
|
|
return axios.get(url, {params})
|
|
|
|
case METHOD.POST:
|
|
|
|
return axios.post(url, params)
|
|
|
|
default:
|
|
|
|
return axios.get(url, {params})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
METHOD,
|
|
|
|
request
|
|
|
|
}
|