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

@apollo/utils.fetcher

v3.1.0

Published

Minimal web-style fetch TypeScript typings

Downloads

4,850,077

Readme

Fetcher interface

This package defines TypeScript typings for a subset of the web fetch API.

The goal is for software that wants to be able to make HTTP requests in a configurable fashion to be able to declare an option of this type; users can pass in any valid fetch implementation such as node-fetch, make-fetch-happen, or undici.

The actual fetch API is very flexible. You can specify requests either as JSON-style objects or as objects of the Request and Headers classes. However, some fetch implementations distinguish between these cases by using (for example) instanceof Headers, where Headers is the particular class defined by that implementation. So if you want to write portable code that should work with any fetch implementation, you need to use JSON-style objects rather than a particular implementation's classes. (For example, a Headers object created with node-fetch v2 will not be properly recognized by make-fetch-happen v10.)

Additionally, some fetch implementations accept various types for their request body; for example, node-fetch supports the use of FormData objects specifically from the form-data package. You may choose to use different types for your request body, so long as those types are supported by the fetch implementation of your choice. You will likely need to use a type assertion to convince TypeScript that your body is valid. Unfortunately, because different fetch implementations access different FormData classes, we weren't excited about the outcome of this relevant PR and decided to undo it, but might be open to a simpler approach that solves the problem without the need for type assertions.

Specifically, the Fetcher interface only declares options that are currently required by the software that uses it, such as Apollo Server and Apollo Gateway. If more options are required (and they are implemented with the same types in all fetch implementations), we can add them as needed.

This package is validated to be compatible with the typings of node-fetch v2, make-fetch-happen v10, and undici v5.