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 Request from '@/common/libs/luch-request/index.js' import App from '@/app.config.js'
const http = new Request() http.setConfig(config => { config.baseURL = App.BASE_URL return config })
function Token () { return uni.getStorageSync('token') || '' }
http.interceptors.request.use(config => { config.header = { ...config.header, token: Token } return config }, config => { return Promise.reject(config) })
http.interceptors.response.use((response) => {
const data = response.data
if(/([1345]\d*)/.test(data.code)) { uni.showToast({ icon: 'none', title: data.msg }) return Promise.reject(response) }
return response }, (response) => { return Promise.reject(response) })
export default http
|