base-service.js
666 Bytes
/**
* 网络请求基类
* @param url 网络请求地址(可选)
* @param other 其他参数(自选)
*
*/
import { GET } from '../../../libs/request';
import {API_HOST} from '../../../libs/config.js';
import regeneratorRuntime from '../../libs/regenerator-runtime/index.js';
export default class BaseService {
constructor() {
this.url = API_HOST;
}
async GET(params, options) {
let path = options && options.path ? options.path: '';
let url = this.url + path;
return await GET(url, {
...params
}).then(res => {
if (res.code === 200) {
return res.data
} else {
throw res
}
})
}
}