@ngify/http-wx
TypeScript icon, indicating that this package has built-in type declarations

2.0.6 • Public • Published

@ngify/http-wx

version Node.js CI License CodeFactor

@ngify/http 的微信小程序 HTTP 请求适配器。

安装

npm install @ngify/http-wx

API

有关完整的 API 定义,请访问 https://ngify.github.io/ngify.

基本用法

import { withWx } from '@ngify/http-wx';

const http = new HttpClient(
  withWx()
);
// or
setupHttpClient(
  withWx()
);

额外参数

小程序请求还支持更多额外的参数,使用 HttpContext 来传递它们:

import { WX_UPLOAD_FILE_TOKEN, WX_DOWNLOAD_FILE_TOKEN, WX_REQUSET_TOKEN } from '@ngify/http-wx';

// 开启 HTTP2
http.get('/api', {
  context: new HttpContext().set(WX_REQUSET_TOKEN, {
    enableHttp2: true,
  })
});

// 文件上传
http.post('url', null, {
  context: new HttpContext().set(WX_UPLOAD_FILE_TOKEN, {
    filePath: 'filePath',
    fileName: 'fileName'
  })
});

// 文件下载
http.get('/api', {
  context: new HttpContext().set(WX_DOWNLOAD_FILE_TOKEN, {
    filePath: 'filePath'
  })
});

Readme

Keywords

none

Package Sidebar

Install

npm i @ngify/http-wx

Weekly Downloads

30

Version

2.0.6

License

none

Unpacked Size

24 kB

Total Files

13

Last publish

Collaborators

  • hyperlife1119