Skip to main content
FastEdge applications can make outbound HTTP calls from inside the handler — reach out to any external service, transform the response, and return the result to the caller. This guide builds an application that fetches a list of users from a public REST API and returns the first five as JSON. It assumes the toolchain is already configured for the chosen language.

Handler

Create a new library crate or project, then write the handler for the chosen language.
Create a library crate and replace Cargo.toml:
Replace src/lib.rs:
Client::new() routes requests through the WASI outbound-http interface — the host runtime handles the actual network call. The await on client.send() is real async: the handler yields while the upstream request is in flight. The response body arrives as a stream; body.contents().await reads it fully into memory before parsing. Every ? propagates errors through anyhow::Result — FastEdge converts a handler returning Err into a 500 response, with the error message written to application logs.

Build

Compile the handler to a WebAssembly binary.
The binary is at ./target/wasm32-wasip2/release/outbound_fetch.wasm.

Deploy

The outbound call happens on every request, from every edge node that handles traffic for this app. For data that changes infrequently, storing the upstream response in a KV store eliminates per-request latency after the first fetch.