1.0.0 • Published 2 years ago

unified-fetch v1.0.0

Weekly downloads
25
License
ISC
Repository
github
Last release
2 years ago

GitHub npm bundle size npm

What is unified-fetch?

unified-fetch is an isomorphic fetch library. It's a wrapper around two libraries. node-fetch for NodeJs and whatwg-fetch for the browser. Depending on the context on which it's executed the correct library is automatically loaded. If you're using a modern browser then unified-fetch uses the built-in fetch implementation and neither library is used.

Installation

Install the unified-fetch package from npm. npm install unified-fetch

Usage

Use unified-fetch in the same way you use built-in fetch.

const response = await unifiedFetch.fetch("http://localhost/basic", {method: HttpMethod.GET});
const result = await response.json();

Instance Options

The following instance initialization options are available.

const unifiedFetch: UnifiedFetch = new UnifiedFetch({
    // ... instance options
});
OptionDescription
prefixUrlPrefix all requests with the specified URL
jwtTokenInclude the specified JWT token (using appropriate auth header)
beforeRequestHookHook into the request before it's been made
afterRequestHookHook into the request after it's been made
headersApply additional headers

Request Options

The following request options are available.

const result = await unifiedFetch.fetch("http://localhost/my-request", {
    // ... request options
});
OptionDescription
jsonAdd the specified object to the request as a JSON message body
queryStringAdd the specified object to the request as a URL encoded query string
1.0.0

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.25

2 years ago

0.0.26

2 years ago

0.0.24

2 years ago

0.0.23

3 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago