npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

updated-fetchit

v3.0.1

Published

Extra utilities for `fetch` that work in both Node and the browser.

Downloads

1

Readme

fetchit

fetchit provides additional utilities for fetch that works in both Node and the browser.

Installation

yarn

yarn add fetchit

npm

npm install --save fetchit

Documentation

By default, fetchit works identically to fetch with the exception that it will throw a StatusCodeError for non-200 responses.

In addition to the standard fetch API, fetchit adds a few extra utilities:

fetchit.json

fetchit.json() accepts the same arguments as fetch, but rather than the full response object, it will return a JSON object:

import fetchit from 'fetchit'
console.log('result', await fetchit.json('https://httpbin.org/anything'))

fetchit.text

fetchit.text() accepts the same arguments as fetch, but rather than the full response object, it will return the response body as a string:

import fetchit from 'fetchit'
console.log('result', await fetchit.text('https://httpbin.org/robots.txt'))

Functional Access

In addition to fetchit.json() and fetchit.text(), you can access them in a functional way as well:

import fetchit, { json, text } from 'fetchit'

console.log('result', await json(fetchit('https://httpbin.org/anything'))
console.log('result', await text(fetchit('https://httpbin.org/robots.txt'))

options

fetchit supports additional options beyond what fetch provides by default:

query

You can pass in a query object to be formatted and tacked onto the URL as a query string:

const fetch = require('fetchit')
console.log(
  'result',
  await fetch.json('https://httpbin.org/get', {
    date: Date.now(),
    boolean: true,
    string: 'string',
  }),
)

form

You can pass in a form object and fetchit will setup an application/x-www-form-urlencoded request body:

const fetch = require('fetchit')
console.log(
  'result',
  await fetch.json('https://httpbin.org/form', {
    method: 'POST',
    form: {
      date: Date.now(),
      boolean: true,
      string: 'string',
    },
  }),
)

body

If you pass an object to body, fetchit will setup a application/json request body:

const fetch = require('fetchit')
console.log(
  'result',
  await fetch.json('https://httpbin.org/form', {
    method: 'POST',
    body: {
      date: Date.now(),
      boolean: true,
      string: 'string',
    },
  }),
)

Note: If you pass in a FormData instance as the value of body or you provide a Content-Type header, the standard fetch behavior will apply for body.

credentials

Unlike fetch, by default, fetchit will set credentials to same-origin.

License

fetchit was created by Shaun Harrison and is made available under the MIT license.