You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
843 B
TypeScript
34 lines
843 B
TypeScript
import { service } from './service'
|
|
|
|
import { config } from './config'
|
|
|
|
const { default_headers } = config
|
|
|
|
const request = (option: any) => {
|
|
const { url, method, params, data, headersType, responseType } = option
|
|
return service({
|
|
url: url,
|
|
method,
|
|
params,
|
|
data,
|
|
responseType: responseType,
|
|
headers: {
|
|
'Content-Type': headersType || default_headers
|
|
}
|
|
})
|
|
}
|
|
export default {
|
|
get: <T = any>(option: any) => {
|
|
return request({ method: 'get', ...option }) as unknown as T
|
|
},
|
|
post: <T = any>(option: any) => {
|
|
return request({ method: 'post', ...option }) as unknown as T
|
|
},
|
|
delete: <T = any>(option: any) => {
|
|
return request({ method: 'delete', ...option }) as unknown as T
|
|
},
|
|
put: <T = any>(option: any) => {
|
|
return request({ method: 'put', ...option }) as unknown as T
|
|
}
|
|
}
|