import { getJson } from "https://deno.land/x/serpapi@1.1.1/mod.ts";
Get a JSON response based on search parameters.
- Accepts an optional callback.
- Get the next page of results by calling the
.next()
method on the returned response object.
Examples
// single call (async/await)
const json = await getJson("google", { api_key: API_KEY, q: "coffee" });
// single call (async/await) const json = await getJson("google", { api_key: API_KEY, q: "coffee" });
// single call (callback) getJson("google", { api_key: API_KEY, q: "coffee" }, console.log);
// pagination (async/await)
const page1 = await getJson("google", { q: "coffee", start: 15 });
const page2 = await page1.next?.();
// pagination (async/await) const page1 = await getJson("google", { q: "coffee", start: 15 }); const page2 = await page1.next?.();
// pagination (callback)
getJson("google", { q: "coffee", start: 15 }, (page1) => {
page1.next?.((page2) => {
console.log(page2);
});
});
// pagination (callback) getJson("google", { q: "coffee", start: 15 }, (page1) => { page1.next?.((page2) => { console.log(page2); }); });