Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

270
Visualizações
Why do I get a cors error when parsing an object

Hi I am currently working on an app that's setting items in localStorage then later retrieve all items. When retrieving I am parsing the object to convert it from a stringified object to an object. On doing that I am getting this error, Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development.

I tried to look for solutions but the one that's suggested is to clear local storage but It's a problem because I'll have to do that each time I press my button. Is there a fix for this.

My code:

// This function gets all items from the local storage
  function getAll() {
    var values = [],
      keys = Object.keys(localStorage),
      i = keys.length;

    while (i--) {
      values.push(localStorage.getItem(keys[i]));
    }
    
    return values;
  }

  const getMissions = getAll();
  // This variable stores the parsed value, ie, turning a stringified object back to an object value
  const { image, missionName } = JSON.parse(getMissions);
  

Thank you in advance

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda