-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from 'axios' | ||
import Qs from 'qs' | ||
axios.defaults.timeout = 15000 | ||
axios.interceptors.request.use( | ||
config => { | ||
config.baseURL = './' | ||
// config.withCredentials = true // 允许携带token ,这个是解决跨域产生的相关问题 | ||
config.timeout = 6000 | ||
return config | ||
}, | ||
error => { | ||
return Promise.reject(error) | ||
} | ||
) | ||
axios.interceptors.response.use( | ||
response => { | ||
return response | ||
}, | ||
error => { | ||
return Promise.reject(error) | ||
} | ||
) | ||
export function get(url, params) { | ||
return new Promise((resolve, reject) => { | ||
axios.get(url, { | ||
params: params | ||
}).then(res => { | ||
resolve(res.data); | ||
}).catch(err => { | ||
reject(err.data) | ||
}) | ||
}); | ||
} | ||
export function post(url, params) { | ||
return new Promise((resolve, reject) => { | ||
axios.post(url, Qs.stringify(params)) | ||
.then(res => { | ||
resolve(res.data); | ||
}) | ||
.catch(err => { | ||
reject(err.data) | ||
}) | ||
}); | ||
} |
Binary file not shown.
This file was deleted.
Oops, something went wrong.