Plugin for Piral that provides a standardized fetch API for pilets (microfrontends), with automatic authentication token injection and middleware support. Current stable version is 1.11.0, released as part of the Piral ecosystem with regular updates. Key differentiators: integrates with Piral's auth system, supports relative URLs to a configurable base URL, offers middleware pipeline for extending fetch behavior, and returns a slightly different response object than the browser fetch.
npm install piral-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up piral-fetch plugin with a base URL and default headers, then uses the fetch API in a pilet.
Use res.code for status code, res.body for parsed JSON (automatically parsed). Do not use res.json().
Always configure a base URL in createFetchApi options, or use absolute URLs.
Ensure fetch calls target the configured base URL, or manually add auth headers for other URLs.
Check the response shape: use .code (number) and .body (parsed JSON).
Run 'npm install piral-fetch' and ensure the import is from 'piral-fetch' (not 'piral-fetch-plugin' or similar).
Change 'import createFetchApi from "piral-fetch"' to 'import { createFetchApi } from "piral-fetch"'.piral-fetch returns { code, body } where body is already parsed. Use res.body directly instead of res.json().