import { getJsonBySearchId } from "https://deno.land/x/serpapi@0.0.3/src/serpapi.ts";
Get a JSON response given a search ID.
- This search ID can be obtained from the
search_metadata.id
key in the response. - Typically used together with the
async
parameter. - Accepts an optional callback.
Examples
const response = await getJson("google", { api_key: API_KEY, async: true, q: "coffee" });
const { id } = response.search_metadata;
await delay(1000); // wait for the request to be processed.
const response = await getJson("google", { api_key: API_KEY, async: true, q: "coffee" }); const { id } = response.search_metadata; await delay(1000); // wait for the request to be processed.
// async/await const json = await getJsonBySearchId(id, { api_key: API_KEY });
// callback getJsonBySearchId(id, { api_key: API_KEY }, console.log);
Type Parameters
R extends BaseResponse
Parameters
optional
parameters: GetBySearchIdParameters = [UNSUPPORTED]optional
callback: (json: R) => void- API key