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

194
Views
Rendering API results

I'm trying to render the "excuse" results from the following API. 'https://excuser.herokuapp.com/v1/excuse' I've followed several tutorials such as this (https://www.youtube.com/watch?v=uxf0--uiX0I) I'm able to pull the data using a button/onclick, however, their methods always generate an "undefined" whenever I try to actually get to the property I need out of the results which is "excuse".

Can you please let me know how to update the code below to pull in the "excuse" results? (It's okay if you're fetch/get request format is different. This is just the last attempt I tried. However, please non-React/Axios. I would like to use vanilla javascript. Thanks in advance!

async function getApi() {
const api_url = 'https://excuser.herokuapp.com/v1/excuse'
const response = await fetch (api_url);
const data = await response.json();
const {excuse} = data;
console.log(excuse);
} 
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

try this

async function getApi() {
  const api_url = 'https://excuser.herokuapp.com/v1/excuse'
  const response = await fetch (api_url);
  const data = await response.json();
  const {excuse} = data[0];
  console.log(excuse);
}

about 4 years ago · Juan Pablo Isaza Report

0

As I see excuse inside an array so you should do data[0] instead of data

async function getApi() {
const api_url = 'https://excuser.herokuapp.com/v1/excuse'
const response = await fetch (api_url);
const data = await response.json();
console.log(data)
const {excuse} = data[0];
console.log(excuse);
} 

getApi();

about 4 years ago · Juan Pablo Isaza Report
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!