התראת לא השתמש ב- promise.catch לכן תיזרק מהתוכנית
-
מעתיק לפה את הפונקציה מהאשכול הסמוך
async function getValue() { let value = 0; let keyes = ['cow', 'deer']; if(any_condition) { await Promise.all( keyes.map( row => { return new Promise((reslove) => { db.get('value', (err, newValue) => { if(err) console.log(err); value += newValue; }); reslove(); }); })); } return new Promise().reslove(value) }לבקשה מה-db יש 2 אפשרויות: 1 הכנסת קול בק ואז התשובה מתקבלת לתוכה 2 בלי קול בק ואז חוזר פרומיס
במידה וכותבים בצורה 2 אם לא מגדירים.catch()גם שגיאת notFound עוצרת את התוכניתהשאלה, בדוגמא כאן כן הכנסתי קול-בק ועם זאת עולה לי השגיאה הזו!
(node:19949) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:19949) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.אולי בגלל השגיאה הקודמת עליה אני שואל באשכול ההוא?
(node:19949) UnhandledPromiseRejectionWarning: TypeError: Promise resolver undefined is not a function -
מעתיק לפה את הפונקציה מהאשכול הסמוך
async function getValue() { let value = 0; let keyes = ['cow', 'deer']; if(any_condition) { await Promise.all( keyes.map( row => { return new Promise((reslove) => { db.get('value', (err, newValue) => { if(err) console.log(err); value += newValue; }); reslove(); }); })); } return new Promise().reslove(value) }לבקשה מה-db יש 2 אפשרויות: 1 הכנסת קול בק ואז התשובה מתקבלת לתוכה 2 בלי קול בק ואז חוזר פרומיס
במידה וכותבים בצורה 2 אם לא מגדירים.catch()גם שגיאת notFound עוצרת את התוכניתהשאלה, בדוגמא כאן כן הכנסתי קול-בק ועם זאת עולה לי השגיאה הזו!
(node:19949) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:19949) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.אולי בגלל השגיאה הקודמת עליה אני שואל באשכול ההוא?
(node:19949) UnhandledPromiseRejectionWarning: TypeError: Promise resolver undefined is not a function
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות