Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

318
Visualizações
Trying to get all the text from an external webpage with JS (JSON in an array)

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

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda