I'm currently working on a function that is designed to extract data from a locally stored .json
file, specifically one called products.json
. The function in question looks like this:
async function getJSON_Format(){
let response = await fetch(api);
let data = await response.json();
// console.log(data);
return data;
}
The variable api
represents the file path for products.json
. My goal is to retrieve all the information contained within products.json and save it as a JSON object variable using a line similar to
let json_object = getJSON_Format();
. However, the current issue is that this returns a promise.
I am seeking advice on how to address this problem. Any suggestions?