@kiter/taro-request
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

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

/@kiter/taro-request/

    Package Sidebar

    Install

    npm i @kiter/taro-request

    Weekly Downloads

    0

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    661 kB

    Total Files

    13

    Last publish

    Collaborators

    • kiter