Spaces:
Sleeping
Sleeping
Update static/script.js
Browse files- static/script.js +7 -2
static/script.js
CHANGED
|
@@ -154,10 +154,15 @@ function getFoodSuggestions() {
|
|
| 154 |
},
|
| 155 |
body: JSON.stringify({ ingredients: selectedIngredients })
|
| 156 |
})
|
| 157 |
-
.then(response =>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
.then(data => {
|
| 159 |
if (data.error) {
|
| 160 |
-
addMessage('bot',
|
| 161 |
} else {
|
| 162 |
addMessage('bot', 'Here are some recipe ideas based on your selected ingredients:');
|
| 163 |
data.suggestions.forEach(suggestion => addMessage('bot', suggestion));
|
|
|
|
| 154 |
},
|
| 155 |
body: JSON.stringify({ ingredients: selectedIngredients })
|
| 156 |
})
|
| 157 |
+
.then(response => {
|
| 158 |
+
if (!response.ok) {
|
| 159 |
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
| 160 |
+
}
|
| 161 |
+
return response.json();
|
| 162 |
+
})
|
| 163 |
.then(data => {
|
| 164 |
if (data.error) {
|
| 165 |
+
addMessage('bot', data.error);
|
| 166 |
} else {
|
| 167 |
addMessage('bot', 'Here are some recipe ideas based on your selected ingredients:');
|
| 168 |
data.suggestions.forEach(suggestion => addMessage('bot', suggestion));
|