I have 2 files named test.js and test2.js , I write a function in test1.js which stores a value in a variable from the function call, but I am unable to access that value in the variable in test2.js file. Whenever I try to do that, it shows undefined.
Can someone please guide me through the same
here are what my 2 files look like
let det='';
let fine='';
async function init(key)
{
try{
det=pkey;
console.log(pkey);
fine = uuidv4();
console.log(fine);
}
catch(error){
console.error(error);
}
}
Now I want to access both det and fine in another file named test2.js , where I use axios
async function getAll(){
try{
const response=await axiosClient.get('/shoes',{ headers: {"key" : `${det}`,"sess":`${fine}`}});
console.log(response.data);
}
catch(error){
console.error(error);
}
}
module.exports.getAll=getAll;