根目录下新建tsg1.js,执行 yarn tsg1 或者 npm run tsg1
如果想要自定义文件名,可加上参数, --c 后跟上文件名即可
module.exports = {
url: 'https://petstore.swagger.io/v2/swagger.json',
output: './src/api',
}
export default {
get<T>(url: string, params) {
const [reqUrl, option] = interceptRequest(url, params)
option.method = 'get'
return fetch(reqUrl, option).then<T>(interceptResponse)
},
post<T>(url: string, params) {
const [reqUrl, option] = interceptRequest(url, params)
option.method = 'post'
return fetch(reqUrl, option).then<T>(interceptResponse)
},
put<T>(url: string, params) {
const [reqUrl, option] = interceptRequest(url, params)
option.method = 'put'
return fetch(reqUrl, option).then<T>(interceptResponse)
},
delete<T>(url: string, params) {
const [reqUrl, option] = interceptRequest(url, params)
option.method = 'delete'
return fetch(reqUrl, option).then<T>(interceptResponse)
},
}