// using Promise
fetch("my.json")
.then(response => response.json())
.then(parsed => /* parsed contains the parsed json object */);
// or if you can use async/await
let response = await fetch("my.json");
let parsed = await response.json();
// using Promise
fetch("my.json")
.then(response => response.json())
.then(parsed => /* parsed contains the parsed json object */);
// or if you can use async/await
let response = await fetch("my.json");
let parsed = await response.json();
// using Promise
fetch("my.json")
.then(response => response.json())
.then(parsed => /* parsed contains the parsed json object */);
// or if you can use async/await
let response = await fetch("my.json");
let parsed = await response.json();
// using Promise
fetch("my.json")
.then(response => response.json())
.then(parsed => /* parsed contains the parsed json object */);
// or if you can use async/await
let response = await fetch("my.json");
let parsed = await response.json();
Using fetch function
Code to access employees.json using fetch function −
fetch("./employees.json")
.then(response => {
return response.json();
})
.then(data => console.log(data));