Skip to content

Commit 831b6ce

Browse files
committed
feat(JS): use array destructuring in server.js
1 parent 6414c1b commit 831b6ce

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

public/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ recipeButtons.forEach((button) => {
321321
}
322322
});
323323
});
324-
325-
console.log(speechBtns);
326-
327-
console.log(speedBtn);
328324
})
329325
.catch((error) => {
330326
console.error("Error:", error);

server.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,26 @@ app.get("/email", async (req, res) => {
5050

5151

5252
app.get("/openai", async (req, res) => {
53-
console.log(req.query);
53+
54+
const {recipe_country_of_origin, is_lactose_intolerant, is_vegan, what_are_user_other_dietary_requirements } = req.query
5455
try {
5556
console.log(
56-
{ country: req.query.recipe_country_of_origin },
57-
{ lactose_intolerant: req.query.is_lactose_intolerant },
58-
{ is_vegan: req.query.is_vegan },
59-
{
60-
user_otherdietary_requirements:
61-
req.query.what_are_user_other_dietary_requirements,
62-
}
57+
{ recipe_country_of_origin },
58+
{ is_lactose_intolerant },
59+
{ is_vegan },
60+
{what_are_user_other_dietary_requirements}
6361
);
6462

6563
const prompt = `Provide a recipe for a dish from ${
66-
req.query.recipe_country_of_origin
64+
recipe_country_of_origin
6765
}, taking into account the fact that I'm ${
68-
req.query.is_lactose_intolerant === "true"
66+
is_lactose_intolerant === "true"
6967
? "lactose intolerant"
7068
: "not lactose intolerant"
71-
} ${req.query.is_vegan === "true" ? "vegan" : "not vegan"} and ${
72-
req.query.what_are_user_other_dietary_requirements === ""
69+
} ${is_vegan === "true" ? "vegan" : "not vegan"} and ${
70+
what_are_user_other_dietary_requirements === ""
7371
? "I have no other dietary requirements"
74-
: req.query.what_are_user_other_dietary_requirements
72+
: what_are_user_other_dietary_requirements
7573
} `;
7674

7775
console.log(prompt);

0 commit comments

Comments
 (0)