JamesJ Posted May 28, 2022 Share Posted May 28, 2022 (edited) I am attempting to set an array equal to an external JSON file. I put the JSON file on google drive and set it to share. I have tried many different examples of code to get the JSON data into the array, but I am stymied. Thanks for any help. Edited May 29, 2022 by JamesJ Link to comment
method Posted May 29, 2022 Share Posted May 29, 2022 Have you tried using a fetch request to handle the retrieval and parsing of the json file? Link to comment
JamesJ Posted May 29, 2022 Author Share Posted May 29, 2022 (edited) Thanks for the response method. I did try this code to read the following simple json file. I uploaded the file to the squarespace site rather than trying to call it from google drive. <script> fetch('https://www.waileage.org/s/testdata.json') .then(response => response.json()) .then(data => console.log(data)); document.getElementById("container").innerHTML = data; </script> json file = [ ['apple', 'fruit', 'red'], ['pear', 'fruit', 'yellow'], ['carrot', 'vegetable', 'orange'], ['eggplant', 'vegetable', 'purple'] ] Edited May 31, 2022 by JamesJ Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment