@onesy/request
v1.0.0
Published
Requests client for browser and nodejs
Downloads
143
Maintainers
Readme
Getting started
Add
yarn add @onesy/request
Use
import OnesyRequest from '@onesy/request';
// Make a new OnesyRequest instance
const onesyRequest = new OnesyRequest();
await onesyRequest.get('https://jsonplaceholder.typicode.com/posts/4');
// or as a static method without a new instance
await OnesyRequest.get('https://jsonplaceholder.typicode.com/posts/4');
// {
// response: {
// userId: 1,
// id: 4,
// title: 'eum et est occaecati',
// body: 'ullam et saepe reiciendis voluptatem adipisci\nsit amet autem assumenda provident rerum culpa\nquis hic commodi nesciunt rem tenetur doloremque ipsam iure\nquis sunt voluptatem rerum illo velit'
// },
// status: 200,
// headers: {
// cache-control: 'max-age=43200',
// content-type: 'application/json; charset=utf-8',
// expires: -1,
// pragma: 'no-cache'
// },
// request: {
// headers: {
// Accept: 'application/json, text/plain, */*'
// }
// },
// options: {
// method: 'GET',
// url: 'https://jsonplaceholder.typicode.com/posts/4',
// request: {
// headers: {
// Accept: 'application/json, text/plain, */*'
// },
// csrf: {
// cookie: 'CSRF-TOKEN',
// headers: 'X-CSRF-TOKEN'
// }
// },
// response: {
// resolveOnError: true,
// type: 'json',
// parse: {
// json: true
// }
// }
// }
// }
Dev
Install
yarn
Test
yarn test
Prod
Build
yarn build