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

136
Views
My local storage is not working, I am trying to push values but I got empty

I am fetching url with a query if the query link is available on my database it will return true, after true I will set the query link into the local storage but when I try to set local storage I got an empty value. I want to push query links in an array but I got this: enter image description here

Here is my code:

  useLayoutEffect(() => {
    fetch(`http://localhost:5000/findUrl/${affiliateLink}`)
      .then(res => res.json())
      .then(data => {
        if (data.isUrlTrue) {
          const affiliate_link = localStorage.getItem('affiliate_Link')
          if (affiliate_link === null) {
            localStorage.setItem('affiliate_Link', [])
          } else {
            let old_Data = JSON.parse(affiliate_link).push(affiliateLink)
            localStorage.setItem('affiliate_Link', JSON.stringify(old_Data))
          }


        }
      })
  })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this

let old_Data = JSON.parse(affiliate_link) || [];
old_Data.push(affiliateLink);
localStorage.setItem('affiliate_Link', JSON.stringify(old_Data));
about 4 years ago · Juan Pablo Isaza Report
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!