//native
type Yelp = {
apiKey: string;
};
/**
* Category Details
* This endpoint returns detailed information about the Yelp category specified by a Yelp category alias. The alias for each category can be found either by using the /v3/categories endpoint, or the category list.
*/
export async function main(
auth: Yelp,
alias: string,
locale: string | undefined,
) {
const url = new URL(`https://api.yelp.com/v3/categories/${alias}`);
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