-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.mjs
More file actions
15 lines (13 loc) · 817 Bytes
/
Copy pathquickstart.mjs
File metadata and controls
15 lines (13 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// DO NOT EDIT BY HAND — StayingAPI examples, generated by the export script. Edit the script + re-run.
// Quickstart: search vrbo stays. Run: node quickstart.mjs
const KEY = process.env.STAYINGAPI_KEY;
if (!KEY) { console.error("Set STAYINGAPI_KEY=stay_..."); process.exit(1); }
const url = new URL("https://api.stayingapi.com/v1/search");
url.searchParams.set("location", "Split, HR");
url.searchParams.set("platforms", "vrbo");
url.searchParams.set("limit", "5");
const resp = await fetch(url, { headers: { Authorization: `Bearer ${KEY}` } });
if (!resp.ok) throw new Error(`HTTP ${resp.status}: ${await resp.text()}`);
const { data, meta } = await resp.json();
for (const stay of data) console.log(stay.platform, "-", stay.name, "-", stay.price);
console.log("platforms:", (meta.platforms || []).join(", "));