fetch
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v13View latest version
Drop-in replacement for JavaScript fetch() that routes requests through rotating proxy IPs via ScraperAPI.
Each request gets a different IP address, useful for scraping and accessing content that blocks datacenter IPs.
import { fetch } from "https://esm.town/v/std/fetch/main.ts";
const res = await fetch("https://httpbin.org/ip");
const json = await res.json();
console.log(json.origin); // A different IP each time
Same signature as native fetch().
Rendering mermaid diagram...
| File | Type | Purpose |
|---|---|---|
main.ts | script | SDK — exports fetch() |
proxy.ts | http | Auth, rate limit, proxy, log |
database.ts | script | SQLite logging + rate limiting |
| Key | Description |
|---|---|
ScraperAPI_KEY | ScraperAPI API key |
100 requests per minute per user. Returns 429 with Retry-After: 60 header when exceeded.
Every request logged to fetch_usage table (indexed on user_id, created_at) with user_id, username, url, method, status_code, timestamp.