i am trying to show data from events.json
file to my website. my code is showing data in console.log
but how can i store it in variable
to resue it, on the website.
events.json file data:
[
{
"id": "d8jai72s",
"name": "Vacations",
"description": "TEST",
"date": "March/16/2022",
"type": "vacation"
}
]
Code to show response in console:
$(document).ready(function() {
fetch("events.json")
.then(response => {
return response.json();
})
.then(jsondata => console.log(jsondata));
i want to use this response here in same .js file:
$("#demoEvoCalendar").evoCalendar({
format: "MM dd, yyyy",
titleFormat: "MM",
calendarEvents: [{
> // i want place response data in calendarEvents here with other events.
id: "d8jai72s",
name: "Vacations",
description: "Winter Vacation Starts (All Classes)",
date: ["January/01/2022", "January/13/2022"],
type: "vacation",
everyYear: 0
}
]
});