Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda