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

196
Views
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
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!