Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
/ nFetch Public archive

⚡ Simplified HTTP request client, inspired in Axios plugin, using fetch native (< 1kb gzip)

License

Notifications You must be signed in to change notification settings

joaoeudes7/nFetch

Repository files navigation

nFetch

Simplified HTTP request client (< 1kb)

npm bundlephobia npm

Config

Methods and Structures

Methods For convenience aliases have been provided for all supported request methods.

nfetch.get = (url: string, configs?: IConfig)
nfetch.delete = (url: string, data?: object, configs?: IConfig)
nfetch.post = (url: string, data: object, configs?: IConfig)
nfetch.put = (url: string, data: object, configs?: IConfig)

Configs Structure

IConfig {
  baseURL?: string;
  cache?: RequestCache;
  credentials?: RequestCredentials;
  headers?: Headers;
  integrity?: string;
  keepalive?: boolean;
  method?: RequestMethod;
  mode?: RequestMode;
  referrerPolicy?: ReferrerPolicy;
  timeout?: number;
}

Response Structure

Response {
  url: string;
  data?: any;
  status: number;
  headers?: Headers;

  /**
   * Funcional only in Typescript
   * T: Something `Class` as parameter
   */
  public toObject<T>() {}
}

Configure API

import { nfetch } from 'nfetch';

const api = new nfetch({ baseUrl: 'https://jsonplaceholder.typicode.com' })

api.get('/posts')
  .then(res => console.log(res.data))
  .catch(error => console.log(error))

Docs Parameters

Click here to view doc of parameters

Demo

Click here to view in Browser: nfetch | Requests | API | Simple Example

About

⚡ Simplified HTTP request client, inspired in Axios plugin, using fetch native (< 1kb gzip)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published