From 58c769de55d3f27b2a893ce32299b714fc48c08f Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 21 Nov 2022 09:43:28 +0200 Subject: [PATCH] Display the day and improve error handling message --- index.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.mjs b/index.mjs index 0a86d79..c5c4b07 100755 --- a/index.mjs +++ b/index.mjs @@ -2,7 +2,7 @@ import fetch from "node-fetch"; const APIURI = "https://fi.jamix.cloud/apps/menuservice/rest/haku/menu/92225/1?lang=fi"; -const myArgs = process.argv.slice(2); +const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; function getAllFoods(data) { // get the list of days and sort them by date ascending (the api for some reason sorts by weekday) @@ -12,7 +12,7 @@ function getAllFoods(data) { const foods = []; days.map((day) => { - foods.push(String(day.date)); + foods.push(`${weekday[day.weekday]}, ${String(day.date)}`); day.mealoptions.map((mealoption, index) => { let str = "" str += mealoption.name + ": " @@ -30,4 +30,4 @@ function getAllFoods(data) { fetch(APIURI) .then(response => response.json()) .then(data => getAllFoods(data).map(food => console.log(food))) - .catch(err => console.error("Error when fetching resource (api endpoint might be down)")); + .catch(() => console.error("Error when fetching resource (api endpoint might be down)"));