Taro 请求库
Promise based HTTP client for the Taro.
Installing
Using npm:
$ npm install @core/taro-request
Using yarn:
$ yarn add @core/taro-request
Example
import request from '@core/taro-request'
request.configure({
successCode: 0,
onSuccess: (res) => {
console.log('正确', res)
},
header: {
devicekind: 'miniProgram',
appName: 'hljPlus',
appKind: 'miniApp'
},
transformRequest: (url: string, data: any) => {
const transformUrl = getPath(url)
return { url: transformUrl, data }
}
})
request.get(
'https://www.exmaple.com',
{ id: 1, name: 'str' },
{
header: {
'Content-Type': 'json'
}
}
)
request.post('https://www.exmaple.com', { id: 1, name: 'str' })