0.0.8 • Published 3 years ago

@preflower/fetch v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Easy Fetch

A fetch-based request library, similar to axios

Installing

$ npm i @preflower/fetch

Example

/* UMD Usage */
const instance = easyFetch.createInstance({
  baseURL: 'https://xiatiande.com',
});

/* ES Usage */
import { createInstance } from 'easy-fetch';

const instance = createInstance({
  baseURL: 'https://xiatiande.com',
});

instance.interceptors.request.use((config) => {
  return config;
});

instance.interceptors.response.use((response) => {
  return response;
});

API (*:default value)

Fetch Config Params

  • method: *GET, POST, HEAD, PUT, DELETE, etc
  • headers: Object / Headers Type
  • body: Blob, BufferSource, FormData, URLSearchParams, USVString; tips: GET, HEAD unsupported
  • mode: *cors, no-cors, same-origin, navigate
  • credentials: omit, *same-origin, include
  • cache: *default, no-store, reload, no-cache, force-cache,only-if-cached
  • redirect: *follow, error, manual
  • integrity: hash 通过传递 hash,验证请求资源完整性
  • keepalive: *false, true 确保请求持续直到结束
  • signal: use for stop request TODO:考虑怎么实现中止请求

Custom API

  • baseURL: ''
  • timeout: 3000
  • escape: text, *json, formData, blob, arrayBuffer

Weakness

  • don't support upload progress
  • can't be aborted directly, need to use AbortController
0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago