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.

40 lines
1005 B

const baseUrl = 'http://localhost:8089'
//const baseUrl = 'http://192.168.31.70:8089'
const http = (options = {}) => {
return new Promise((resolve, reject) => {
uni.request({
url: baseUrl + options.url || '',
method:options.type || 'GET' ,
data: options.data || {},
header: options.header || {},
}).then((response) => {
console.log(response)
resolve(response.data);
}).catch(error => {
reject(error)
})
});
}
const get=(url,data,options={})=>{
options.type='get';
options.data = data;
options.url = url;
return http(options)
}
const post = (url, data, options = {}) => {
options.type = 'post';
options.data = data;
options.url = url;
return http(options)
}
const put = (url, data, options = {}) => {
options.type = 'put';
options.data = data;
options.url = url;
return http(options)
}
export default {
get,
post,
put
}