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.
38 lines
1013 B
38 lines
1013 B
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> { |
|
return new Promise(resolve => { |
|
Dec.reqGet(getFullUrl(url), '', re => { |
|
resolve(re); |
|
}); |
|
}); |
|
} |
|
|
|
export function requestPost(url: string, data = {}): Promise<ResultType> { |
|
return new Promise(resolve => { |
|
Dec.reqByEncrypt("POST", getFullUrl(url), data, re => { |
|
resolve(re); |
|
}); |
|
}); |
|
} |
|
|
|
export function requestDelete(url: string, data = {}) { |
|
return new Promise(resolve => { |
|
Dec.reqByEncrypt("DELETE", getFullUrl(url), data, re => { |
|
resolve(re); |
|
}); |
|
}); |
|
} |
|
|
|
export function requestPut(url: string, data = {}) { |
|
return new Promise(resolve => { |
|
Dec.reqByEncrypt("PUT", getFullUrl(url), data, re => { |
|
resolve(re); |
|
}); |
|
}); |
|
}
|
|
|