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

242
Views
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 answers
Answer question

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