import { request } from '@tarojs/taro' ; type RequestOpts = Omit < request . Option , 'url' > ; const safeRequest = ( url , options ) => { return new Promise ( ( resolve , reject ) => { request ( { method : 'GET' , ... options , header : { 'Content-Type' : 'application/json' , ... options ?. header , } , url , } ) . then ( response => { resolve ( response ?. data ?? response ) ; } , err => { reject ( err ) ; } ) ; } ) ; } ; param url param opts returns { Promise } const get = async ( url , opts ) : Promise < any > => { return safeRequest ( url , opts ) ; } ; param url param opts returns { Promise } const post = async ( url , opts ) : Promise < any > => { return safeRequest ( url , { ... opts , method : 'POST' , } ) ; } ; param url param opts returns { Promise } const put = async ( url , opts ) : Promise < any > => { return safeRequest ( url , { ... opts , method : 'PUT' , } ) ; } ; export default { get , post , put , } ;