0.0.1 • Published 1 year ago

@kiter/taro-request v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

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' })
0.0.1

1 year ago