//native
type Yelp = {
apiKey: string;
};
/**
* Featured Event
* This endpoint returns the featured event for a given location. Featured events are chosen by Yelp's community managers.
*/
export async function main(
auth: Yelp,
location: string | undefined,
latitude: string | undefined,
longitude: string | undefined,
locale: string | undefined,
) {
const url = new URL(`https://api.yelp.com//v3/events/featured`);
for (const [k, v] of [
["location", location],
["latitude", latitude],
["longitude", longitude],
["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