• Empleos
  • Sobre nosotros
  • Empleos
    • Inicio
    • Empleos
    • Cursos y retos
  • Empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

219
Vistas
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?

over 3 years ago · Santiago Trujillo
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda