@wepy/use-intercept

2.1.0 • Public • Published

@wepy/use-intercept

weapp APIs intercept factory.

Install

npm install @wepy/use-intercept --save

Usage

Basic Usage

import wepy from '@wepy/core';
import useIntercept  from '@wepy/use-intercept';

wepy.use(useIntercept);

const request = wepy.intercept(wepy.wx.request, {
  config(params) {
    console.log(params);
    if (!params.data) {
      params.data = {};
    }
    params.data.t = +new Date();
    return params;
    // return Promise.resolve(params); // support async config interceptor
  },
  success(res) {
    console.log(res);
    return res;
  },
  fail(e) {
    console.log(e);
    return e;
  }
})

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @wepy/use-intercept

      Weekly Downloads

      1

      Version

      2.1.0

      License

      MIT

      Unpacked Size

      11.8 kB

      Total Files

      7

      Last publish

      Collaborators

      • dlhandsome
      • gcaufy