嗨我试图通过执行一个属于另一个模块(另一个JavaScript文件)的函数来解析已经解析的Promise,以便通过.then得到值。 。Nodejs将promise解析传递给另一个模块以获取值
这是我的代码:
saveUrl.js文件:
const manager = require('./manager');
.then(()=>{
return new Promise((resolve, rej)=>{
\t resolve(mainUrl)
//here if I put .then I have the value that I want BUT I want the value to be passed to the manager file
manager.getSavedUrlPromise()
})
})
法力ger.js文件:
const mongoSavedUrl = require('./saveUrl');
module.exports={
getSavedUrlPromise(){
return mongoSavedUrl
.then(()=>{
console.log("inside getSavedUrlPromise")
console.log(promise)
process.exit()
})
}
}
它告诉我说:
mongoSavedUrl.then is not a function
'决心(mainUrl)' - 这是什么 “决心”,没有承诺明显的在那里做什么?另外,saveUrl.js没有导出,也没有任何东西返回任何地方 –