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

277
Views
Pushing Function Array into ;Another Array

I am developing a recipe website in which I am using an API to pull in ingredients and nutritional information. On my site, I am wanting to have a person search to add ingredients from this and only this list. I'm pretty green with javascript, so this likely is user error. What I've found so far is this:

const api_url = `https://reqres.in/api/users`;
const matchList = document.getElementById('results');

function getData(){
    fetch(api_url).then(response =>{
        return response.json();
    }).then(data =>{
        const html = data.data.map(user =>{
            return `"${user.first_name}"`
        }).join(',');
        console.log(html);
    });
};

let suggestions = [
    "Taco",
];

I'm needing the "let suggestions = []" for a different piece of code, but I'm unable to capture the array that is found in the getData() function. Any thoughts on how to go about this?

about 4 years ago · Santiago Trujillo
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!