Hello everyone! I have come across a URL: . My goal now is to extract the value (Price) of a specified key (name).
I am aware that there have been similar inquiries in the past, but unfortunately, I haven't been able to make it work as JSON is relatively new to me.
If possible, I would like to achieve this using javascript.
I am counting on your assistance!
While browsing through other questions, I stumbled upon something like this, but couldn't quite get it to function properly:
var accessJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('get', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
callback(null, xhr.response);
} else {
callback(status);
}
};
xhr.send();
};
accessJSON('https://www.googleapis.com/freebase/v1/text/en/bob_dylan', function(err, data) {
if (err != null) {
alert('Oops, an error occurred: ' + err);
} else {
alert('Here is your Json result: ' + data.result);
result.innerText = data.result;
}
});
At present, the code I am working with looks like this:
accessJSON('https://api.csgofast.com/price/all', function(err, data) {
if (err != null) {
console.log("There was an issue retrieving pricing information!");
} else {
console.log("Item price : " + data['Sticker | Good Game']);
}
});