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

144
Views
my swift-executing functions are skipping over values

I'm working with an API in JS to create a movie info website and I'm calling an async function 3 times that fetches different endpoints based on the parameters I pass in.

I mapped across each object(value) in the 'result'(property of parsed response) array in order to set it's respective 'poster-path' property value as the respective image element's src attribute. it worked fine, but since i called the function thrice, anytime I try to target the object whose index is equal to that of my target image element, it seems to target only the objects gotten in the final function call.

    let result = res.json().result
    let imageID = e.target.data-id;
    let targetObject = result[imageID];

if I try to access targetObject's movie ID property for example, and the e.target is the image with an index of 0 in the first movie display(result of the first function call), rather than targetting the targetObject with an index of 0 in the same first movie display, it will target the object with an index of 0 in the third movie display.

Please how do I target the object with the same index as my e.target and in the 'same' display without it being overridden by the last. I'm very sorry if I didn't word this correctly, I'm still new to programming.

almost 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!