From 4192845cef54362cd7179c2d0492ede730ac0d8e Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Wed, 1 Nov 2023 18:39:24 +0100 Subject: [PATCH] It might help to feed an object to a function that expects an object --- main.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index 3f9d9dd..6f5d151 100644 --- a/main.js +++ b/main.js @@ -5,7 +5,7 @@ function initLists (lists){ const menuContainer = document.getElementById('menu-container'); - menus.forEach( menu =>{ + lists.forEach( menu =>{ const dropdownMenu = document.createElement('menu'); const menuTitle = Object.assign(document.createElement('h2'), {innerHTML:menu.name}); const description = Object.assign(document.createElement('p'), {innerHTML:menu.description}); @@ -30,13 +30,11 @@ document.getElementById('import').onclick = function() { return false; } - const fr = new FileReader(); + const fr = new FileReader(); - fr.onload = function(e) { - console.log(e); - const result = JSON.parse(e.target.result); - initLists(JSON.stringify(result, null, 2)); - } + fr.onload = function(e) { + initLists(JSON.parse(e.target.result)); + } - fr.readAsText(files.item(0)); + fr.readAsText(files.item(0)); };