Skip to content

nRFCloud/fetch-with-debug

Repository files navigation

@nrfcloud/fetch-with-debug

https://jsr.io/@nrfcloud/fetch-with-debug

Simple wrapper around fetch that logs request and response.

Install with NPM

npx jsr add (--save-prod|--save-dev) @nrfcloud/fetch-with-debug

Usage

import { fetchWithDebug } from "@bifravst/fetch-with-debug";

const fetch = fetchWithDebug(
  (type, details) => console.log("[My Service]", type, JSON.stringify(details)),
  (args) => console.error("[My Service]", JSON.stringify(args)),
  (args) => console.debug("[My Service]", JSON.stringify(args)),
);

const res = await fetch(new URL("https://example.com"));

About

Simple wrapper around fetch that logs request and response.

Resources

License

Stars

Watchers

Forks

Packages

No packages published