Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Fetching Menu - Invalid JSON Response #1

Closed
wiesty opened this issue Aug 19, 2024 · 1 comment
Closed

Error Fetching Menu - Invalid JSON Response #1

wiesty opened this issue Aug 19, 2024 · 1 comment
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@wiesty
Copy link
Owner

wiesty commented Aug 19, 2024

Description:

When using the MMM-Mensamuc module, an error occurs when attempting to fetch the menu data from the API. The error appears to be triggered when the API responds with an HTML document (e.g., a 404 page) instead of the expected JSON format. This results in the following error being logged:

MMM-Mensamuc.js:38 Error fetching menu: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON MMM-Mensamuc.js:29 GET https://tum-dev.github.io/eat-api/mensa-lothstr/2024/34.json 404 (Not Found)

Steps to Reproduce:

  1. Set up the MMM-Mensamuc module.
  2. Configure the module to use a canteen for which there is no data available (e.g., by setting the canteen property to mensa-lothstr during a week where the data file is not available).
  3. Observe the error in the developer console.

Expected Behavior:

If the API response is not valid JSON or if a 404 error occurs, the module should handle the error gracefully by displaying a message such as "No menu available yet" instead of logging a syntax error.

Actual Behavior:

The module attempts to parse the HTML error page as JSON, leading to a syntax error being logged in the console.

@wiesty wiesty added bug Something isn't working enhancement New feature or request labels Aug 19, 2024
@wiesty wiesty self-assigned this Aug 19, 2024
@wiesty
Copy link
Owner Author

wiesty commented Aug 19, 2024

Fixed with Commit afbcc2e22eecce6e4e028e3ded594b48b07d49e0

@wiesty wiesty closed this as completed Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant