זה נושא דיון מלווה לערך המקורי ב- https://www.tocode.co.il/bundles/nodejs/lessons/16-events
זה נושא דיון מלווה לערך המקורי ב- https://www.tocode.co.il/bundles/nodejs/lessons/16-events
ינון תודה על השיעור המקסים:)
מה זה בדיוק?
.bind(this)
הי
כל הנושא מוסבר בקורסים של JavaScript מומלץ להתחיל משם:
https://www.tocode.co.il/bundles/frontend
שיעורים 38-55
הכי טוב שתסתכל שם על השיעורים אחד אחד בטאב טקסט לקרוא זריז וכשתתחיל להגיע לנושאים שלא מכיר תכנס לוידאו
Hi Yinon!
9:20
You show using await inside try/catch outside async function, I got error on that.
//asyncNum.js
async function asyncFunc()
{
return 17;
}
module.exports.asyncFunc = asyncFunc;
//index.js
const {asyncFunc} = require("./asyncNum");
try {
const numResult = await asyncFunc();
console.log("textResult = ",numResult);
}
catch(error) {
throw error;
}
Hi Avraham,
You need to use await inside an async function
Can you share the error you got?
const numResult = await asyncFunc();
^^^^^
SyntaxError: await is only valid in async function
←[90m at wrapSafe (internal/modules/cjs/loader.js:984:16)←[39m
←[90m at Module._compile (internal/modules/cjs/loader.js:1032:27)←[39m
←[90m at Object.Module._extensions…js (internal/modules/cjs/loader.js:1097:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:933:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:774:14)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m
כן אז זה בדיוק מה שכתבתי - אי אפשר לכתוב await סתם כך מחוץ לכל פונקציה. זה חייב להיות בתוך איזושהי פונקציה המסומנת בתור async