I've been experimenting with a way to transfer JSON data from one page to another by using local storage.
For instance, when a user clicks on a specific book image, they are directed to book.html where the image and book name are displayed (retrieved from the json file).
FIGMA PROTOTYPE -
script.js
const petsData = [{
name: "Story Book",
species: "Jean Lumier", //THIS IS THE JSON FILE
photo: "a.jpg"
},
{
name: "Barksalot",
species: "Dog",
href:"href.img,
photo: "https://learnwebcode.github.io/json-example/images/dog-1.jpg"
},
];
function petTemplate(pet) {
return `
<div class ="image-grid">
<div class="animal">
<img class="pet-photo " src="${pet.photo}" >
<div class="olay" onclick="location.href='${pet.href}';" style="cursor: pointer;">
<div id="mydiv">
<h2 class="pet-name">${pet.name}
<h1 class="species">${pet.species}
</div>
<div></div></div>
</div>
</div>
`;
}
Thank you for your time.