I'm trying some things with JS to get all smartphones brands. I found this API : GSMArena API
As you can see, the content is on an array, and I don't know how to get informations in this case.
I thought about different things. I would like to take all the text from URL, remove the array symbols as a string, and then, just take informations with parsing. That's certainly not the best idea possible.
I tried several things to do that, and none are working (using fetch, request, axios ...) :
var getJSON = 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.response);
}
};
xhr.send();
};
getJSON("https://gsmarena-api.herokuapp.com/brands", function (err, data) {
if (err !== null) {
alert("Something went wrong: " + err);
} else {
console.log(data)
}
});
If you could help me with what I'm trying to, or if you have another idea, that would help a lot ! Thanks :D