嗨我試圖通過執行一個屬於另一個模塊(另一個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沒有導出,也沒有任何東西返回任何地方 –