Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!