Skip to content

介绍

SDK 中提供了几套对应的 API 请求域名,大家可直接导出使用,无需重复定义

  • 支持请求增加对应 token
  • 支持无痛刷新 token
  • 支持各个业务的返回结构体

对应的环境就是快速上手章节初始化时传递给 SDKENV 参数,SDK 会根据环境自动切换 baseUrl

baseApi

mocktestrcprod
http://localhost:${h5SDKConfig.mockerPort}/basehttp://test-api.xxx.cnhttps://rc-api.xxx.cnhttps://api.xxx.cn

wxApi

mocktestrcprod
http://localhost:${h5SDKConfig.mockerPort}/wxhttps://test-wx.xxx.cnhttps://rc-wx.xxx.cnhttps://wx.xxx.cn

使用示例

TIP

所有的 API 都是基于 axios 封装的,对应的使用方法也可参照 axios 官网

ts
import { baseApi } from '@sxwy/h5-sdk'

export const getUserInfo = (data: { type: string }) => {
  return baseApi.request<{
    token: string
  }>({
    method: 'POST',
    url: '/api/getUserInfo/v1.0',
    data
  })
}

Last updated:

Released under the MIT License