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

206
Vistas
How to access JSON information from fueleconomy.gov API using JavaScript?

How would I go about accessing the following api with Javascript? https://www.fueleconomy.gov/feg/ws/ They state that "Data are available in either JSON or XML format." and I have no clue how to actually access it in JSON format.

I'm new to using APIs and my end goal is to be able to view the MPG of user searched vehicles.

I've used the following code to get a working XML response in the console:

console.log('starting')
request.open('GET', 'https://www.fueleconomy.gov/ws/rest/vehicle/emissions/31873', true)

request.onload = function () {
    var parser, xmlDoc;
    var data = this.response

    parser = new DOMParser();
    xmlDoc = parser.parseFromString(data,"text/xml");

    console.log(xmlDoc)
}

request.send()
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