123456789101112131415161718192021222324 |
- const BASE_URL = 'https://m.douban.com'
- export const newRequest = (options) => {
- return new Promise((resolve,reject)=> {
- uni.request({
- url: BASE_URL + options.url, //仅为示例,并非真实接口地址。
- method: options.method || 'GET',
- data: options.data || {},
- header: {
- 'custom-header': 'hello' //自定义请求头信息
- },
- success: (res) => {
- console.log(res.data);
- resolve(res);
- },
- fail:(err) => {
- uni.showToast({
- title:"请求失败"
- })
- reject(err);
- }
- });
- })
- }
|