From d27533ab6701cee8157d39b7c2ab6d2922c90e2e Mon Sep 17 00:00:00 2001 From: Alex Jerabek <38896772+AlexJerabek@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:15:04 -0700 Subject: [PATCH] [excel-insert-file] Fix JSON data import (#593) * Fixing JSON variable scope * Remove temp files --- Samples/excel-insert-file/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Samples/excel-insert-file/index.js b/Samples/excel-insert-file/index.js index 0d0a3c9c8..a07bb1438 100644 --- a/Samples/excel-insert-file/index.js +++ b/Samples/excel-insert-file/index.js @@ -49,11 +49,13 @@ async function insertSheets() { const sheet = context.workbook.worksheets.getItem("Template"); // Get data from your REST API. For this sample, the JSON is fetched from a file in the repo. + let json; let response = await fetch(dataSourceUrl + "/data.json"); if (response.ok) { - const json = await response.json(); + json = await response.json(); } else { console.error("HTTP-Error: " + response.status); + return; } // Map JSON to table columns.