KyleWynne / Health_Blocks

1 stars 5 forks source link

If Given Empty Text Input #7

Open iorlovic opened 11 months ago

iorlovic commented 11 months ago

First of all, I think your project is really cool and you did a good job executing it. I ran the code as described in the readme and it successfully ran, so that is working fine. Then I ran it with an empty text input for the food name and it returned an error: * total calories: 700 Error: Error: Error: HTTP response code 400 at /Users/ivanorlovic/Desktop/Health_Blocks/code-1.js:20:12 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) / One suggestion that may be worth addressing is adding a clearer error message to tell the user what they are missing in their blockly code. Maybe within apitest.js, specifically this code: / fetch(apiUrl, { headers }) .then((response) => { if (response.status === 200) { return response.json(); } else { throw new Error(Error: HTTP response code ${response.status}); } }) .then((data) => { console.log(data); }) .catch((error) => { console.error('Error:', error); }); */ You could potentially add a clearer error message. I noticed if I tried to leave the calorie intake as no input, it automatically reverted to 0, which I think does a good job as it has a default. Overall, great job.

KyleWynne commented 11 months ago

Thank you for the feedback! I think you and Kevin had the same Idea. I think the best way to remedy this is to add a default search if its empty just in case.