I have a function like this below,
class MyClass {
myFunction() {
return new Promise((resolve, reject) => {
if(....) {
resolve(data)
} else {
reject(err)
}
})
}
}
module.exports = MyClass;
I can reach this class from another files like this below
const MyClass = require('./fileName.js').prototype;
const exportData = MyClass.myFunction().then(data => {
return data;
}).catch(err => {
console.log(err)
})
console.log(exportData) //exportData is not null
module.exports = exportData;
when I want to export this exportData
to other files, value of exportData
is null in other files. But if I do not export this exportData
, it is not null.
How can solve this problem ?
Thanks.