A tiny (~1.8KB gzipped) wrapper built around fetch with an intuitive syntax.
npm i wretch
yarn add wretch
pnpm add wretch
bun add wretch
<script src="https://unpkg.com/wretch"></script>
Build beautiful, chainable HTTP requests in seconds
wretch()
.json({ name: "John Doe", email: "[email protected]" }) // .formData, .formUrl…
See all the pieces come together in one beautiful chain
import wretch from "wretch"
const user = await wretch("https://jsonplaceholder.typicode.com/users")
.json({ name: "John Doe", email: "[email protected]" })
.post()
.notFound(err => console.log("User not found"))
.error(500, err => console.log("Server error"))
.json()
console.log(user)