Skip to content

If Given Empty Text Input #7

@iorlovic

Description

@iorlovic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions