//native
type Yelp = {
apiKey: string;
};
/**
* Food & Drinks Insights
* This endpoint returns the list of food & drinks offered at the business, including what is trending and the raw food ingredients needed.
This endpoint is part of Yelp Fusion Insights, visit Yelp Fusion Insights to learn more.
*/
export async function main(
auth: Yelp,
business_id_or_alias: string,
locale: string | undefined,
) {
const url = new URL(
`https://api.yelp.com/v3/businesses/${business_id_or_alias}/insights/food_and_drinks`,
);
for (const [k, v] of [["locale", locale]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago