how to fetch json data js code example
Example 1: How to Use the JavaScript Fetch API to Get Data
fetch('http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(JSON.stringify(myJson));
});
Example 2: javascript fetch json
fetch('./yourjson.json')
.then((response) => response.json())
.then((data) => {
console.log(data);
})
Example 3: javascript parse json
var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson);
Example 4: object json parse javascript
var objJson1 = JSON.parse(JSON.stringify(objNotJson1));