New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

icfetcher

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icfetcher

Library to facilitate the creation of reusable fetchers

latest
npmnpm
Version
1.1.0
Version published
Weekly downloads
5
-16.67%
Maintainers
1
Weekly downloads
 
Created
Source

icfetcher npm version

icfetcher is a JavaScript library for creating fetchers using fetch method with a variety of settings.

Usage

const fetcher = ({ url, method, body }) => {
  return fetchFactory({
    baseUrl: "https://pokeapi.co/api/v2",
    isJson: true, // Content-Type and Accept header = application/json
    url,
    method, // GET (default)
    body,
    autoBodyStringfy: true, // parse array to json string
    autoClearUndefinedBodyAttributes: true // remove nulls attributes
})

// without fetch wrapper
fetcher({url: '/pokemon/magikarp'})
  .then(response => response.json())  
  .then((response) => {
      console.log(response.forms[0].name)
    })
    .catch(error => console.log(error))

// with fetch wrapper
fetchWrapper(fetcher({url: '/pokemon/magikarp'}))
  .then(({status, data}) => {
    console.log(status ,data.forms[0].name)
  })
  .catch(error => console.log(error))
// catch and throw errors and transform result to json

FAQs

Package last updated on 18 Feb 2023

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