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

129
Views
Update JSON function not returning updated JSON object

I have a function that takes in a JSON object and edits a value based on a condition. I am struggling to find the correct way to return the new updated JSON object. When I console.log(testBookmarks) after I see the updated object but when I stringify it and try to use it in another function it seems to be the old non-updated object.

Function:

const iterate = (obj) => {
  Object.keys(obj).forEach(key => {
  // console.log('key: '+ key + ', value: '+obj[key]);
  if(key === "url"){
    fetch(obj[key])
  .then(response => {
     console.log(response)
     console.log(response.status);
     if(response.status != 200){
       console.log(obj)
       obj[key] = "null"
       console.log(obj)
       return 
       
     }
     
  })
  .catch(error => console.error(error));
  }

  if (typeof obj[key] === 'object') {
          iterate(obj[key])
      }
  })
}

iterate(testBookmarks)
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!