best-request
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

bestpay 前端请求库,包括入向网关、PC 网关请求。

安装

npm install best-request

使用

import BestRequest from "best-request";
// 请求基础参数,具体请求参数参考dist/http/index.d.ts
const baseConfig = {
  baseURL: "请求根地址",
  token: "请求toekn",
  tenantId: "租户id",
  data: {}, // 请求参数
  env: {
    yzfPublicKey: "xxx",
    certificateSerial: "xxx",
    app_id: "",
    env: "环境标", // 生产不需要
    sessionKey: "xxx", // pc网关需要
    userId: "xxx", // pc网关需要
  },
};

const url = "每个接口后缀地址";
await BestRequest.requestBridge({
  url,
  ...baseConfig,
});
// 加密方法,请求拦截器中可使用
BestRequest.getGwPcEncryptParam(
  JSON.stringify(baseConfig.data),
  baseConfig.env
);
// 解密方法,响应拦截器中可使用
BestRequest.gwPcDecrypt(res.data.result)

Readme

Keywords

none

Package Sidebar

Install

npm i best-request

Weekly Downloads

106

Version

1.0.11

License

none

Unpacked Size

483 kB

Total Files

10

Last publish

Collaborators

  • bestpay_kf_web