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

243
Visualizações
While retrieving the dataStore.js object throws undefined in js file

I have created a dataStore.js object and tried to pass below string to object as below. Getting undefined while console.log in Home.js, could someone please advise the issue here.

let dataStore = {
    globaldata1: {},
    globaldata2: {}
}

export { dataStore }

// profile.js

let datastore = require("../global/dataStore");

let myStr1 = "This is a string" ;
let myStr2 = "This is another string" ;
datastore.globaldata1 = myStr1;
datastore.globaldata2 = myStr2;

// home.js

let datastore = require("../global/dataStore");

let globalStr1 = datastore.globaldata1 ;
console.log("Print the data::"+globalStr1);

let globalStr2 = datastore.globaldata2  ;
console.log("Print the second data::"+globalStr2);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It would seem the issue here is that you didn't properly capitalize your import.

Your export from dataStore.js is:

export { dataStore }

Where the S is capitalized, but in your Home.js:

const { datastore } = reqiure(...)

It doesn't have a capitalized S which would make the import undefined because dataStore.js doesn't export datastore, it exports dataStore

about 4 years ago · Juan Pablo Isaza Relatório
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