hw-api-fetch
Install
npm install --save hw-api-fetchoryarn add hw-api-fetch
Usage
First you have to pass the properties of your api to the HWApiFetch component:
const properties = host: 'https://www.yourapi.com.br/api/' cookiesToHeader: key: 'authId' cookie: 'authentication' 'authorization' beforeReturn: {return ...res test: true} log: true hwResponse: true HWApiFetch
The properties are:
Key | Type | Description |
---|---|---|
host | string | The host of your api. |
cookiesToHeader | array | Array of objects with the format {key, cookie}. If is passed a string it will be presumed that the key and the cookie are equals. If these cookies exists in the browser, it will be send with all your requests. |
beforeReturn | array | Array of functions to be applied before the data returns. |
log | boolean | Log api calls to the console. Default false. |
hwResponse | boolean | Data comes with hwResponse format. Default false. |
noContentType | boolean | Remove default content-type sended in the header. Default false. |
fetchProperties | object | Add properties to fetch options. |
Then you can make the calls to your api:
HWApiFetchHWApiFetchHWApiFetchHWApiFetchHWApiFetch
get, post, put, patch, delete params are:
Param | Type | Description |
---|---|---|
path | string | The path of your call. |
data | object | The data that you want to send. |
License
MIT © daniellrs