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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@microsoft/kiota-http-fetchlibrary

v1.0.0-preview.110

Published

Kiota request adapter implementation with fetch

Readme

Microsoft Kiota HTTP - Fetch library

npm version badge

The Kiota Http Fetch Library is an implementation using the Fetch API to make requests.

A Kiota generated project will need a reference to an HTTP implementation to make calls to an API endpoint.

Read more about Kiota here.

Using the Kiota Fetch library implementations

  1. npm i @microsoft/kiota-http-fetchlibrary @microsoft/kiota-bundle @microsoft/kiota-abstractions.

Send cookies with a custom fetch function

To send cookies to an API from a browser, configure a custom fetch function with credentials: "include" and pass it to KiotaClientFactory.create(). Use the resulting HTTP client when constructing your request adapter:

import { AnonymousAuthenticationProvider } from "@microsoft/kiota-abstractions";
import { DefaultRequestAdapter } from "@microsoft/kiota-bundle";
import { KiotaClientFactory } from "@microsoft/kiota-http-fetchlibrary";

const customFetch = (url: string, init: RequestInit) =>
	fetch(url, { ...init, credentials: "include" });

const httpClient = KiotaClientFactory.create(customFetch);
const authProvider = new AnonymousAuthenticationProvider();
const adapter = new DefaultRequestAdapter(authProvider, undefined, undefined, httpClient);

Use your API's authentication provider in place of AnonymousAuthenticationProvider when the API requires one. In browsers, cross-origin cookie requests also require the API to allow credentialed CORS requests and the cookies to have compatible attributes.

Body Inspection Handler

The BodyInspectionHandler middleware allows you to inspect HTTP request and response bodies. This is particularly useful for debugging or capturing error payloads that are not mapped in the API schema.

The handler is included in the default middleware pipeline configured by KiotaClientFactory.create().

Configuration

Body inspection is opt-in and controlled via BodyInspectionOptions. You can configure it globally on the handler or per-request by passing BodyInspectionOptions in the request options.

import { BodyInspectionOptions } from "@microsoft/kiota-http-fetchlibrary";

const bodyInspectionOptions = new BodyInspectionOptions({
	inspectRequestBody: true,
	inspectResponseBody: true,
});

// Pass per request using request configuration:
await client.users.get({
	options: [bodyInspectionOptions],
});

// Access the inspected body as an ArrayBuffer:
const responseBuffer = bodyInspectionOptions.responseBody;

Memory and Stream-Lifecycle Considerations

  • Memory / Buffering: Inspecting request and response bodies creates in-memory copies (ArrayBuffer). For large payloads or file transfers, buffering the entire body into memory increases heap usage. Only enable inspection when necessary.
  • Stream Lifecycle: In JavaScript and browser fetch implementations, ReadableStream instances are single-use and can only be consumed once.
    • Web ReadableStream and Node.js readable request bodies are buffered once and replaced with replayable bytes before the request continues downstream. This consumes the original stream so a permitted retry can reuse the inspected request body. Retry eligibility is still controlled by RetryHandler; for example, it does not retry application/octet-stream POST, PUT, or PATCH requests.
    • In the performance middleware pipeline, stream buffering requires inspectRequestBody: true. Compression does not accept an uninspected stream body.
    • The captured request and response bodies are exposed as ArrayBuffer values. Callers that need another representation can construct it explicitly from those bytes.
  • Concurrent requests: Use a separate request-scoped BodyInspectionOptions instance for each request whose captured body you need to read. A handler's global options instance is shared across requests.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.