1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { fetch } from "https://esm.town/v/std/fetch";
import { email } from "https://esm.town/v/std/email?v=9";
import process from "node:process";
export const sendFoodEmail = async () => {
const randomNumber = Math.floor(Math.random() * 80);
let recipeName = "";
let recipeDescription = "";
let pictureUrl = "";
let videoLink = "";
const url =
"https://tasty.p.rapidapi.com/recipes/list?from=0&size=80&tags=under_30_minutes";
const options = {
method: "GET",
headers: {
"X-RapidAPI-Key": process.env.tastyAPIKey,
"X-RapidAPI-Host": "tasty.p.rapidapi.com",
},
};
try {
const response = await fetch(url, options);
const result = await response.json();
recipeName = result.results[randomNumber].name;
recipeDescription = result.results[randomNumber].description;
pictureUrl = result.results[randomNumber].thumbnail_url;
videoLink = result.results[randomNumber].original_video_url;
}
catch (error) {
console.error(error);
}
let subject = `My daily (fast and yummy) recipe`;
let html = `<h1>${recipeName}</h1>
<p>Heute habe ich folgende Idee:</p>
<p>${recipeDescription}</p>
<img src=${pictureUrl} />
<a href=${videoLink} target="_blank">Video</a>
<p>Dazu ein Glas Chardonnay!
</p>`;
await email({ html, subject });
};
// Forked from @enyo.sendTelegramMessage
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023