//native
type Tomorrow = {
apiKey: string;
};
/**
* On-Demand Events
*
*/
export async function main(
auth: Tomorrow,
body: { location: string; insight: string },
) {
const url = new URL(`https://api.tomorrow.io/v4/events-timeline`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
ApiKey: auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago