1.3.8 • Published 4 years ago

simple-fetch-wrapper v1.3.8

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

Simple Fetch Wrapper

Simple wrapper around fetch.

For own purposes initially...

GET and POST

Use

npm i simple-fetch-wrapper
import http from 'simple-fetch-wrapper'

API Examples

   import http from 'simple-fetch-wrapper'

   http.setBaseUrl(url: string);

   http.setDefaultContentType('application/json');

   const url = http.getBaseUrl('/api/v1/endpoint');
   
   http.interceptor(requestConfig => {

      console.log(requestConfig);

      requestConfig.headers.append('Authorization', `Bearer ${token}`);

      return requestConfig;
   })

   http.isFetching(status: boolean) => console.log(status));

   http.on('customEvent', (data) => console.log(data));

   http.emit('customEvent', data);

   http.detach('customEvent', Function);

Supports GET and POST

   const args = {
      params: {post: 71}
   };

   const response = await http.get(url, args)


   const args = {
      headers: {'Content-Type': 'application/json'},
      body: {name: 'Some name', id: 1}
   }; 

   const response = await http.post(url, args);

Args

PropertiesType
headers{key: string: string}
body{key: string: any}
params{key: string: any}
1.3.7

4 years ago

1.3.6

4 years ago

1.3.8

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.0

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.13

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago