Fetch API & HTTP Clients
Bun includes a high-performance implementation of the Fetch API. It's fully compatible with the web standard and works seamlessly for making HTTP requests.
Basic Fetch
The fetch API works just like in browsers:
Loading Bun Playground...
POST Requests
Send data with POST requests:
Loading Bun Playground...
Request Headers
Add headers to your requests:
Loading Bun Playground...
Handling Responses
Process different response types:
Loading Bun Playground...
Error Handling
Handle network and HTTP errors gracefully:
Loading Bun Playground...
Exercise: API Client
Create a simple API client function:
Loading Bun Exercise...
Exercise: Request Builder
Create a reusable request builder:
Loading Bun Exercise...

