@beisen/platform-fetch

1.1.0 • Public • Published

platform-fetch 使用说明

安装

  1. npm install @beisen/platform-fetch --save

使用方式

import fetch from '@beisen/platform-fetch'

const requestUrl = 'fetchUrl';

const options = {
  method, // GET, POST, PUT, DELETE
  params, // 请求的参数,GET请求会追加到url之后,其余请求会放到body上
  headers, /*自定义头,默认头
                Accept: "application/json, application/xml, text/play, text/html, *.*",
                Content-Type: "application/json"
           */
  mode,  // 跨域设置
  credentials //cookie策略
};



// fetch全局配置
const globalInjection = {
  //GET请求追加的随机数的key,现在默认是 time ,用来防止请求有缓存
  randomKeyForURL: 'string',

  //全局header,追加在每次请求上
  headers: {},

  //网关需要的header获取位置
  gateWayHeadersPath: 'string',
  // window上属性名,目前主要是获取,网关需要的header,用来追踪整体调用链,没有可以不传,尽量传。
  // 每个请求都会获取一遍, 如果不传,默认获取 window.__gateway_header__ 位置的数据
  /*
  {
    fan: 'string', // 按钮编码
    fal: 'string', // 按钮名称
    fpn: 'string', // 页面编码
    fpl: 'string', // 页面描述
    fver: 'string' // 前端使用的版本
  }
  */

 context: {
   //获取当前租户
   getTenantId: 'function' ,
   //获取当前用户
   getUserId: 'function',
   //获取当前应用
   getCurrentApplication: 'function'
 }

}

fetch(url,options, globalInjection) => Promise

Readme

Keywords

none

Package Sidebar

Install

npm i @beisen/platform-fetch

Weekly Downloads

4

Version

1.1.0

License

ISC

Unpacked Size

8.21 kB

Total Files

4

Last publish

Collaborators

  • albert-zhang
  • liugenpeng
  • beisencorp
  • lgm
  • neozw