# @beisen/platform-fetch

> #### 安装

Latest version **1.1.0** (published 2019-07-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @beisen/platform-fetch
pnpm add @beisen/platform-fetch
yarn add @beisen/platform-fetch
bun add @beisen/platform-fetch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-07-11 |
| First published | 2019-04-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | beisencorp, lgm, neozw |

## Links

- npm: https://www.npmjs.com/package/@beisen/platform-fetch
- Repository: git@gitlab.beisencorp.com:ux-share-platform/ux-platform-fetch
- npm.io page: https://npm.io/package/@beisen/platform-fetch

## Dependencies (4)

- [uuid](https://npm.io/package/uuid.md) 3.3.2
- [whatwg-fetch](https://npm.io/package/whatwg-fetch.md) ^3.0.0
- [promise-polyfill](https://npm.io/package/promise-polyfill.md) ^8.1.0
- [url-search-params](https://npm.io/package/url-search-params.md) ^1.1.0

## Recent versions

- 1.1.0 (latest) — 2019-07-11
- 1.0.0 — 2019-04-28

## README

### platform-fetch 使用说明

#### 安装

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

#### 使用方式

```javascript
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
```

---
_Source: https://npm.io/package/@beisen/platform-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
