|
|
@ -1,10 +1,13 @@ |
|
|
|
import { ResultType } from './crud.typings.d'; |
|
|
|
import { ResultType } from './crud.typings.d'; |
|
|
|
import { ReqPath } from '../constants/env'; |
|
|
|
import { ReqPath } from '../constants/env'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getFullUrl(url: string) { |
|
|
|
|
|
|
|
return url ? `${ReqPath}/${url}` : ReqPath; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function requestGet(url: string, data?: any): Promise<ResultType> { |
|
|
|
export function requestGet(url: string, data?: any): Promise<ResultType> { |
|
|
|
return new Promise(resolve => { |
|
|
|
return new Promise(resolve => { |
|
|
|
Dec.reqGet(`${ReqPath}/${url}`, '', re => { |
|
|
|
Dec.reqGet(getFullUrl(url), '', re => { |
|
|
|
resolve(re); |
|
|
|
resolve(re); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -12,7 +15,7 @@ export function requestGet(url: string, data?: any): Promise<ResultType> { |
|
|
|
|
|
|
|
|
|
|
|
export function requestPost(url: string, data = {}): Promise<ResultType> { |
|
|
|
export function requestPost(url: string, data = {}): Promise<ResultType> { |
|
|
|
return new Promise(resolve => { |
|
|
|
return new Promise(resolve => { |
|
|
|
Dec.reqPost(`${ReqPath}/${url}`, data, re => { |
|
|
|
Dec.reqPost(getFullUrl(url), data, re => { |
|
|
|
resolve(re); |
|
|
|
resolve(re); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -20,7 +23,7 @@ export function requestPost(url: string, data = {}): Promise<ResultType> { |
|
|
|
|
|
|
|
|
|
|
|
export function requestDelete(url: string, data = {}) { |
|
|
|
export function requestDelete(url: string, data = {}) { |
|
|
|
return new Promise(resolve => { |
|
|
|
return new Promise(resolve => { |
|
|
|
Dec.reqDelete(`${ReqPath}/${url}`, data, re => { |
|
|
|
Dec.reqDelete(getFullUrl(url), data, re => { |
|
|
|
resolve(re); |
|
|
|
resolve(re); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -28,7 +31,7 @@ export function requestDelete(url: string, data = {}) { |
|
|
|
|
|
|
|
|
|
|
|
export function requestPut(url: string, data = {}) { |
|
|
|
export function requestPut(url: string, data = {}) { |
|
|
|
return new Promise(resolve => { |
|
|
|
return new Promise(resolve => { |
|
|
|
Dec.reqPut(`${ReqPath}/${url}`, data, re => { |
|
|
|
Dec.reqPut(getFullUrl(url), data, re => { |
|
|
|
resolve(re); |
|
|
|
resolve(re); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|