@just-web/fetch
v2.0.1
Published
just-web gizmo for fetch API
Readme
@just-web/fetch
@just-web/fetch provides fetch API for a @just-web applications.
Install
# npm
npm install @just-web/fetch
# yarn
yarn add @just-web/fetch
# pnpm
pnpm install @just-web/fetch
#rush
rush add -p @just-web/fetchMigration
2.0.0
- Removed automatic importing
cross-fetch/polyfillin testing entry. - Consumers running in Node environments (without native
fetch) must now provide their own polyfill — for example, by usingundicior importingcross-fetchexplicitly in their test setup. - This change resolves ESM compatibility issues encountered when using Vitest, as the previous
cross-fetch/polyfillimport relied on CommonJS semantics.
Usage
import { justApp } from '@just-web/app'
import { fetchGizmo } from '@just-web/fetch'
const app = await justApp({ name: 'your-awesome-app' })
.with(fetchGizmo)
.create()
app.fetch(...)Testing
@just-web/fetch provides a fetchTestGizmoFn() under @jest-web/fetch/testing.
It can be used during tests to stub the fetch behavior.
import { justTestApp } from '@just-web/app/testing'
import { fetchTestGizmoFn } from '@just-web/fetch/testing'
const app = await justTestApp().with(fetchTestGizmoFn({
fetch(...args) { /* ..snap.. */ }
}))