forked from csci5117s24/project-2-the-flask-fusion-force-2-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exampleAPICall.js
29 lines (25 loc) · 996 Bytes
/
exampleAPICall.js
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
const ingredientsList = ['apples', 'flour', 'sugar'];
// Convert the array of ingredients into a string
const ingredientsStr = ingredientsList.join(',');
// async function callAPI({params, request}) {
// const authToken = 'userHash1'; // User's login token
// const apiUrl = 'searchRecipes/?ingredients=apples,+flour,+sugar&number=2';
// const headers = {
// 'Authorization': authToken,
// 'x-api-key': process.env.SPOONACULAR_API_KEY // If doing a request to spoonacular
// };
// try {
// const response = await fetch(apiUrl, {
// headers: headers
// });
// if (!response.ok) {
// throw new Error('Failed to fetch data');
// }
// const data = await response.json();
// console.log(data);
// return { todoItems: data.data };
// } catch (error) {
// console.error('Error fetching data:', error);
// return { error: 'Failed to fetch data' };
// }
// }