fetch-client-api
create a fetch client api 💫
Usage
installation
# 🔥 yarn add fetch-client-api node-fetch # or good old npm npm i -S fetch-client-api node-fetch
Examples
const fetch = // import libconst createClient = // Setup your clientconst TOKEN = '9c3e88c1e2a7168c8c2a4f88d13bf248f505e40df41fe3a89ee4e7d528af3c0b'const client = baseUrl: 'http://localhost:3002/json/200' headers: Authorization: `Bearer ` queryParams: token: 'BASDFKJASDF' // for status codes > 299 it will throw an error// if response is json you can access by error.payload// extra fields provided error.statusCode error.statusText // sample request callclient // payload of a GET request is transform to query-stringclientapi // you can provide a map function and a grab function if the response is not an arrrayclientapi // you can .get, .post, put, .deleteclientapi