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

202
Vistas
can console.log() a value but not append it to an array

I have a JS/Svelte project fetching some data from an internal API endpoint. I can console.log() the value I need but not append it to an array. Can anybody help me? This is the code, this one works perfectly, giving me back the ID I need:

let tracks = []
async function createTrack(name, artists) {   
        const track_id = await fetch("/api/createtrack", {
            method: 'POST',
            body: JSON.stringify({  name: name,
                                    artists: artists,
                                    release: release._id
                                    })
            }).then((response) => response.json()).then((data) => {return data.id;});
        console.log(track_id)   
    }

but this doesn't, I can't append to the array:

let tracks = []
async function createTrack(name, artists) {   
        const track_id = await fetch("/api/createtrack", {
            method: 'POST',
            body: JSON.stringify({  name: name,
                                    artists: artists,
                                    release: release._id
                                    })
            }).then((response) => response.json()).then((data) => {return data.id;});
        tracks.push(track_id)   
    }
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