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

jfetch

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jfetch

Utility for json only comms via fetch

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

jfetch

jfetch is a small library that makes it easier to use the fetch library. Use it if you have an all json communication with your rest endpoint

Install

npm install --save jfetch

Usage


//es6 modules
import jfetch from 'jfetch';

//amd
const { jfetch } = require('jfetch');
//amd alt
const jfetch = require('jfetch').default;

Quick Usage

//standard get 

//process json here is a function
jfetch('/api/inventories')
    .then( processJson );

//post
jfetch.post('/api/inventories', { id: 'xY33bG', name: 'New Inventory' })
    .then( processJson );

Customizing Jfetch

You can use jfetch such that you are able to change the behavior on how each of the requests behaves. This is done using the createJfetch function.

import { createJfetch } from 'jfetch'; //es6 modules

//const { createJfetch } = require('jfetch'); //amd

const jfetch = createJfetch({ autoBust: false });

jfetch('/api/inventories').then(...); //...will not auto bust get

Settings for custom jfetch

  1. withConfig - function that returns an extra configuration to be merged with the requests
  2. onRespose - function that can receive response data

Keywords

FAQs

Package last updated on 29 Apr 2017

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