Reputation: 105
I'm stuck hours on some weird problem i did tens of this kind operation, but for some reason in one of the files other required files return as empty and the functions cannot be accessed.
here are the exporting file, file name is "user-repo.js"
:
const constants = require('./constants');
const parseRepo = require('./parse-repo');
const updateEmail = (userID, email) => {
return new Promise((resolve, reject) => {
parseRepo.getUser(userID).then((user) => {
if(user != undefined){
user.set(constants.EMAIL_KEY, email);
return parseRepo.saveObject(user);
}
}).then((user) => {
resolve(user);
}).catch((e) => reject(e));
})
};
module.exports = {
updateEmail
}
and in another file where i want to use this function (updateEmail
) i do like this:
const userRepo = require('./user-repo');
function(){
.....
userRepo.updateEmail(userID,email);
}
and it throws error that updateEmail is not a function
, i debugged this and saw that the required object (userRepo
) is empty and have no function, the thing is that second before in other file i do the same thing and userRepo
is working good and have all function.
all this files are in same folder
any idea?
Upvotes: 1
Views: 1337