0
我試圖將量角器代碼與mailosaur集成來處理電子郵件功能,但無法在量角器中編碼時讀取值。當我在node.js中嘗試相同的代碼時,它工作正常,我可以獲取該值。下面是代碼:無法從量角器使用量角器獲取值,儘管它與node.js一樣正在使用
在Node.js的文件:
var Mailosaur = require("mailosaur")("Your_API_Key");
var mailbox = new Mailosaur.Mailbox("MailboxID");
console.log("Here it begins!");
mailbox.getEmails(function(err, emails) {
console.log(err);
console.log(emails);
console.log("Are you even going inside?");});
運行它在CMD:節點filename.js
結果:顯示JSON格式的數據在cmd中。
與量角器代碼相同的東西不起作用,下面是代碼。
describe('Test Mail', function() {
it('should display the data', function(){
var Mailosaur = require("mailosaur")("Your_API_Key");
var mailbox = new Mailosaur.Mailbox("MailboxID");
console.log("Here it begins!");
mailbox.getEmails(function(err, emails) {
console.log(err);
console.log(emails);
console.log("Are you even going inside?");});})});
運行它使用配置文件提相應的規範文件:量角器config.js
結果:出現即只有頂端日誌,不顯示的內容「這開始了!」與上面的情況一樣使用node.js發送郵件。
請建議萬一我失去了一些東西。
感謝您的答覆,但它不是以這種方式工作。雖然當我在回調函數完成後添加睡眠後嘗試時,它獲得了預期的結果。但我正在尋找更好的方法來處理它,而不是使用睡眠。 – Ankit