基于uni.app封装接口请求,含请求拦截器响应拦截器
一、创建request.js 文件(api文件夹=>request.js)
//配置基础地址
const BASE_URL = 'xxx'
//默认请求头
const acquiesceContenttype = 'application/x-www-form-urlencoded'
export default {
config: {
// 请求拦截器
beforeRequest(options = {
}) {
// console.log('请求拦截器', options)
return new Promise((resolve, reject) => {
options.url = BASE_URL + options.url;
options.method = options.method || 'GET';
options.data = options.data;
options.timeout