1.0.0-alpha.5 • Published 4 years ago

quickfetch v1.0.0-alpha.5

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

QuickFetch

a fetch wrapper like axios, support middlewares & abort

1. How to install

npm i quickfetch --save

2. How to use

see test/QuickFetch.test.js

OR vue-cli-3-preset

3. API

Classes

Typedefs

QuickFetch ⇐ MiddlewareHolder

QuickFetch

Kind: global class
Extends: MiddlewareHolder

new QuickFetch(option)

a fetch-based HTTP request tool

ParamType
optionoption

quickFetch.get(url, params, option) ⇒ Promise

make a GET fetch

Kind: instance method of QuickFetch
Returns: Promise - a Promise that resolves to a Response object
See: QuickFetch#constuctor

ParamTypeDescription
urlstring
paramsObject | nullan optional params object
optionoption

quickFetch.post(url, params, option) ⇒ Promise

make a POST fetch

Kind: instance method of QuickFetch
Returns: Promise - a Promise that resolves to a Response object

ParamTypeDescription
urlstring
paramsObject | nullan optional params object
optionoption

quickFetch.delete(url, params, option) ⇒ Promise

make a DELETE fetch

Kind: instance method of QuickFetch
Returns: Promise - a Promise that resolves to a Response object

ParamTypeDescription
urlstring
paramsObject | nullan optional params object
optionoption

quickFetch.put(url, params, option) ⇒ Promise

make a PUT fetch

Kind: instance method of QuickFetch
Returns: Promise - a Promise that resolves to a Response object

ParamTypeDescription
urlstring
paramsObject | nullan optional params object
optionoption

quickFetch.patch(url, params, option) ⇒ Promise

make a PATCH fetch

Kind: instance method of QuickFetch
Returns: Promise - a Promise that resolves to a Response object

ParamTypeDescription
urlstring
paramsObject | nullan optional params object
optionoption

quickFetch.sequence(requestPromiseArr) ⇒ Array.<Response>

make batch requests

Kind: instance method of QuickFetch

ParamType
requestPromiseArrArray.<Promise>

quickFetch.use(type, middleware, fetchId) ⇒ object

regist a middleware

Kind: instance method of QuickFetch
Returns: object - actions - { unuse, pause, resume }

ParamTypeDescription
typestringQuickFetch.REQUESTQuickFetch.RESPONSEQuickFetch.ERROR
middlewarefunctiona function looks like (req|res|err, next) => {}
fetchIdstring | numbera optional id for special requests

QuickFetch.REQUEST

Kind: static property of QuickFetch

QuickFetch.RESPONSE

Kind: static property of QuickFetch

QuickFetch.ERROR

Kind: static property of QuickFetch

QuickFetch.EXCEPTION_TIMEOUT

Kind: static property of QuickFetch

QuickFetch.EVENT_FETCH_ABORT

Kind: static property of QuickFetch

QuickFetch.abort(id)

cancel a fetch action

Kind: static method of QuickFetch

ParamTypeDescription
idstring | number | symbolfetchId

MiddlewareHolder ⇐ EventTarget

MiddlewareHolder

Kind: global class
Extends: EventTarget

middlewareHolder.use(type, middleware, fetchId) ⇒ object

regist a middleware

Kind: instance method of MiddlewareHolder
Returns: object - actions - { unuse, pause, resume }

ParamTypeDescription
typestringQuickFetch.REQUESTQuickFetch.RESPONSEQuickFetch.ERROR
middlewarefunctiona function looks like (req|res|err, next) => {}
fetchIdstring | numbera optional id for special requests

option : Object | Null

an optional object for Request API

Kind: global typedef
Properties

NameTypeDefaultDescription
methodstringstandard fetch init option
credentialsstring"include"standard fetch init option
modestring"cors"standard fetch init option
cachestring"reload"standard fetch init option
headersObjectstandard fetch init option
baseURLstringoptional, an url prefix
timeoutstring30000optional, timeout
catchErrorbooleantrueoptional, if true then just parse error in middleware, otherwise throw it to endpoint
ignoreBodyMethodsArray'get', 'head'optional
forceJSONbooleanfalseoptional, send body with JSON.stringify()
fetchIdstring | number | symboloptional, an unique ID of every fetch request
signalAbortSignaloptional, a given signal to cancel the fetch request
1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago

0.1.1

4 years ago

0.1.0

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago