Browse Source

fix: 修改写法

research/10.0
alan 5 years ago
parent
commit
4c69a4eeb4
  1. 19
      src/modules/crud/crud.service.ts

19
src/modules/crud/crud.service.ts

@ -1,42 +1,37 @@
import { ResultType } from './crud.typings.d';
import { ReqPath } from '../constants/env';
function getFullUrl(url: string) {
return url ? `${ReqPath}/${url}` : ReqPath;
}
export function requestGet(url: string, data?: any): Promise<ResultType> {
const requestURL = url ? ReqPath : `${ReqPath}/${url}`;
return new Promise(resolve => {
Dec.reqGet(requestURL, '', re => {
Dec.reqGet(getFullUrl(url), '', re => {
resolve(re);
});
});
}
export function requestPost(url: string, data = {}): Promise<ResultType> {
const requestURL = url ? ReqPath : `${ReqPath}/${url}`;
return new Promise(resolve => {
Dec.reqPost(requestURL, data, re => {
Dec.reqPost(getFullUrl(url), data, re => {
resolve(re);
});
});
}
export function requestDelete(url: string, data = {}) {
const requestURL = url ? ReqPath : `${ReqPath}/${url}`;
return new Promise(resolve => {
Dec.reqDelete(requestURL, data, re => {
Dec.reqDelete(getFullUrl(url), data, re => {
resolve(re);
});
});
}
export function requestPut(url: string, data = {}) {
const requestURL = url ? ReqPath : `${ReqPath}/${url}`;
return new Promise(resolve => {
Dec.reqPut(requestURL, data, re => {
Dec.reqPut(getFullUrl(url), data, re => {
resolve(re);
});
});

Loading…
Cancel
Save