Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nfetch

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nfetch

Simplified HTTP request client (< 1kb)

  • 1.5.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 24 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc