<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ASYNC/AWAIT]]></title><description><![CDATA[<p dir="rtl">האם פונקציה שמכילה שורה של AWAIT<br />
לא תמשיך הלאה לפני שתקבל תשובה?<br />
אם כן אז מדוע זה לא כך ?<br />
אני קוראת לפונקציה שמחזירה פרומיס עם ASYNC/AWAIT<br />
אך הפונקציה מדפיסה את השורה הבאה לפני שקבלה את התשובה מהפונקציה הפנימית</p>
]]></description><link>https://tchumim.com/topic/11410/async-await</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 17:53:33 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/11410.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Jun 2021 08:29:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 11:09:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
עדיין מענין אותי מה קורה בפונקציה הנ"ל שכתבתי<br />
מדוע הערך חוזר כUNDEFINDE<br />
בזמן שלפני החזרה הוא כן מדפיס לי תוכן</p>
]]></description><link>https://tchumim.com/post/124377</link><guid isPermaLink="true">https://tchumim.com/post/124377</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 11:09:04 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 11:06:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
בSUSCRIPTION<br />
יש את הID של הMEMBER<br />
ומערך של MOVIES שמכיל רק את הID'S<br />
וחוץ מזה יש גם<br />
MOVIES שמכיל ID ועוד כמה פרטים<br />
וMEMBER שמכיל ID<br />
CITY<br />
EMAIL<br />
NAME</p>
]]></description><link>https://tchumim.com/post/124376</link><guid isPermaLink="true">https://tchumim.com/post/124376</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 11:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 11:02:26 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> ענית לי רק על השאלה האחרונה...</p>
]]></description><link>https://tchumim.com/post/124374</link><guid isPermaLink="true">https://tchumim.com/post/124374</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 11:02:26 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:47:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
זה הדרישה של הפרויקט</p>
]]></description><link>https://tchumim.com/post/124373</link><guid isPermaLink="true">https://tchumim.com/post/124373</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:47:51 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:43:31 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> לא היה לפני כן City וכל זה? ורק למי שיש הרשמה לMovie צריך את הפרטים או לכולם?<br />
לא עדיף שהשרת בgetAllMembers ייתן פרטים מלאים?</p>
]]></description><link>https://tchumim.com/post/124372</link><guid isPermaLink="true">https://tchumim.com/post/124372</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:43:31 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:41:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
לפני הGETMEMBER<br />
יש רק את הID שלו<br />
ואני רוצה ליצור JSON שמכיל גם את הפרטים שלו</p>
]]></description><link>https://tchumim.com/post/124371</link><guid isPermaLink="true">https://tchumim.com/post/124371</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:39:47 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> אמר ב<a href="/post/124367">ASYNC/AWAIT</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
נראה נכון<br />
אני כבר בודקת<br />
רק מענין אותי למה בקוד הראשוני ששמתי (תקנתיקצת)<br />
הfinalMmArr מדפיס תוכן<br />
בזמן שהRESULT מדפיס אחרי כן UNDEFINDED</p>
</blockquote>
<p dir="rtl">לפני התיקון של <a class="plugin-mentions-user plugin-mentions-a" href="/user/yossiz" aria-label="Profile: yossiz">@<bdi>yossiz</bdi></a> (לשים return או await) זה לא הגיוני שהוא הדפיס not-found.<br />
אחרי התיקון, הוא היה אמור להדפיס את זה אבל בתוך מערך [.... .... "not-found"]</p>
]]></description><link>https://tchumim.com/post/124369</link><guid isPermaLink="true">https://tchumim.com/post/124369</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:39:47 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:37:23 GMT]]></title><description><![CDATA[<p dir="rtl">חיסרתי את העיקר לכאורה שזה ה<code>await membersRest.getMember(memId);</code> אבל עשיתי זאת במודע, כי אני לא מבין מה הוא מביא (מה היה קודם ומה הוא מחליף/מוסיף).</p>
]]></description><link>https://tchumim.com/post/124368</link><guid isPermaLink="true">https://tchumim.com/post/124368</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:37:23 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:37:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
נראה נכון<br />
אני כבר בודקת<br />
רק מענין אותי למה בקוד הראשוני ששמתי (תקנתיקצת)<br />
הfinalMmArr מדפיס תוכן<br />
בזמן שהRESULT מדפיס אחרי כן UNDEFINDED</p>
]]></description><link>https://tchumim.com/post/124367</link><guid isPermaLink="true">https://tchumim.com/post/124367</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:34:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a> גם הקוד הזה ארוך מידי, כי אני שם לב שהMap הראשון לא עושה כלום, הקוד הזה שקול:</p>
<pre><code>const getAllMembers = async function () {
    let membersArr = await membersRest.getAllMembers();

    let ss = await subscriptionRest.getSubscriptions();
    let ssData = ss.data;

    for (const sub of ss.data) {
        var memberFind = membersArr.find(x =&gt; x._id == sub.MemberID);
        if (memberFind)
            memberFind.Movies = sub.Movies;
        else
            console.log(`the member ${sub.MemberID} not found in the members list, but have subscrition!`)
    }

    return membersArr;
}
</code></pre>
]]></description><link>https://tchumim.com/post/124366</link><guid isPermaLink="true">https://tchumim.com/post/124366</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:34:45 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:31:40 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> אני לא לגמרי מבין, כתבתי שלד קוד שלכאורה עושה כל מה שקיים כעת, תוכלי לומר מה חסר בו?</p>
<pre><code>const getAllMembers = async function () {
    let members = await membersRest.getAllMembers();

    let membersArr = members.data.map(z =&gt; {
        return {
            _id: z._id,
            Name: z.Name,
            Email: z.Email,
            City: z.City,
            Movies: []
        }
    });

    let ss = await subscriptionRest.getSubscriptions();
    let ssData = ss.data;

    for (const sub of ss.data) {
        var memberFind = membersArr.find(x =&gt; x._id == sub.MemberID);
        if (memberFind)
            memberFind.Movies = sub.Movies;
        else
            console.log(`the member ${sub.MemberID} not found in the members list, but have subscrition!`)
    }

    return membersArr;
}
</code></pre>
]]></description><link>https://tchumim.com/post/124365</link><guid isPermaLink="true">https://tchumim.com/post/124365</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:31:40 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:22:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
MEMBER:</p>
<pre><code>Name: String,
Email: String,
City: String
</code></pre>
<p dir="auto">Subscriptions</p>
<pre><code>MemberId: String,
Movies: [String]
</code></pre>
<p dir="rtl">הפונקציה getAllMembers<br />
מציגה את כל הלקוחות אבל אמורה לבדוק אם יש להם מנוי לסרטונים<br />
לכן היא מטעינה את כל המנויים ועבור כל מנוי שולחים לפונקציה השניה getSsForMembers<br />
שם בודקת אם יש למנוי _ID שמתאים לאאחד מה MemberId של המנויים<br />
ומחזירה את המערך של כל המנויים .<br />
קוראים לפונקציה getAllMembers פעם אחת</p>
]]></description><link>https://tchumim.com/post/124362</link><guid isPermaLink="true">https://tchumim.com/post/124362</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:22:38 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:19:43 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> ss.map הופך את מערך הss למערך של פונקציות await, כל אחת מהסוג שכתובה בסוגריים... כלומר הטיפול של הפונקציה יתבצע מול כל פריט בעוד הוא נכתב כנראה במקור לטיפול בכלל המערך ביחד. אשמח לדעת מה הפונקציה עושה, נראה שהיא מאחדת בין שני רשימות שונות, ובנוסף מבקשת מהשרת השלמת מידע.</p>
]]></description><link>https://tchumim.com/post/124361</link><guid isPermaLink="true">https://tchumim.com/post/124361</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:19:43 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:17:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/dovid" aria-label="Profile: dovid">@<bdi>dovid</bdi></a><br />
אז איך במקרה זה מתאימה הפונקציה<br />
יש כאן רק קריאה אחת של AWAIT</p>
]]></description><link>https://tchumim.com/post/124360</link><guid isPermaLink="true">https://tchumim.com/post/124360</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:17:53 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:17:10 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> הפונקציה Promise.all מטפלת במקרה שיש הרבה await לעשות ואת רוצה לחכות שכולם יתבצעו ולקבל את התוצאות כמערך.</p>
]]></description><link>https://tchumim.com/post/124359</link><guid isPermaLink="true">https://tchumim.com/post/124359</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:17:10 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:14:55 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> יש בקוד בעיה נוספת, הפונקציהבPromise.all נקראת עבור כל אחד מהפריטים ברשימה, ומחזירה עבור כל אחד או not-found או אובייקט משותף לכלל האיברים.<br />
הפונקציה הקוראת בודקת אם הערך הוא not-found אבל הוא לעולם לא יהיה  not-found כי התוצאה של Promise.all היא תמיד מערך של תוצאות (בכל תוצאה יכול להיות not-found).<br />
בקיצור הפונקציה getSsForMembers צריכה כתיבה מחדש, אשמח לעזור אם אדע בגדול מה היא מנסה לעשות.</p>
]]></description><link>https://tchumim.com/post/124358</link><guid isPermaLink="true">https://tchumim.com/post/124358</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:14:55 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:14:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yossiz" aria-label="Profile: yossiz">@<bdi>yossiz</bdi></a><br />
נכון זה עזר<br />
האמת שהPROMISE.ALL<br />
כבר היה חלק מהפתרון<br />
מה הוא בעצם פותר ?<br />
הוא לא אמור לבוא כשיש כמה קריאות אסיכרוניות?<br />
בפונקציה זו יש קריאה אחת בתוך הסוגריים של PROMISE.ALL<br />
אז איך זה פתר את הבעיה?</p>
]]></description><link>https://tchumim.com/post/124357</link><guid isPermaLink="true">https://tchumim.com/post/124357</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:14:25 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:04:46 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> צריך להוסיף await או return לפני promise.all</p>
]]></description><link>https://tchumim.com/post/124356</link><guid isPermaLink="true">https://tchumim.com/post/124356</guid><dc:creator><![CDATA[yossiz]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:04:46 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 09:46:15 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a><br />
הMEMBER מובא ע"י REST API</p>
]]></description><link>https://tchumim.com/post/124354</link><guid isPermaLink="true">https://tchumim.com/post/124354</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 09:46:15 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 09:41:45 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%9E%D7%95%D7%98%D7%99-%D7%90%D7%95%D7%A8%D7%9F" aria-label="Profile: מוטי-אורן">@<bdi>מוטי-אורן</bdi></a><br />
תקנתי את הקוד<br />
הRESULT מודפס לפני MEM</p>
]]></description><link>https://tchumim.com/post/124353</link><guid isPermaLink="true">https://tchumim.com/post/124353</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 09:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 09:39:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yossiz" aria-label="Profile: yossiz">@<bdi>yossiz</bdi></a> נראה לי היא מתתכוונת לקוד שנמצא בהערה (שורה 24). <a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> הוא לא אמור להיות עם await בכלל לפי מה שאני מבין פה.</p>
<p dir="rtl"><strong>עריכה:</strong> נראה לי שטעיתי. על פניו כן צריך את ה await</p>
]]></description><link>https://tchumim.com/post/124352</link><guid isPermaLink="true">https://tchumim.com/post/124352</guid><dc:creator><![CDATA[מוטי אורן]]></dc:creator><pubDate>Mon, 21 Jun 2021 09:39:11 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 09:14:09 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A9%D7%A8%D7%94-%D7%A8%D7%97%D7%9C" aria-label="Profile: שרה-רחל">@<bdi>שרה-רחל</bdi></a> ומה השאלה? איפה הפונקציה ממשיכה לפני קבלת תשובה?</p>
]]></description><link>https://tchumim.com/post/124351</link><guid isPermaLink="true">https://tchumim.com/post/124351</guid><dc:creator><![CDATA[yossiz]]></dc:creator><pubDate>Mon, 21 Jun 2021 09:14:09 GMT</pubDate></item><item><title><![CDATA[Reply to ASYNC/AWAIT on Mon, 21 Jun 2021 10:38:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/yossiz" aria-label="Profile: yossiz">@<bdi>yossiz</bdi></a></p>
<pre><code>c

const getAllMembers = async function() {
    let members = await membersRest.getAllMembers();
    let membersData = members.data;

    let membersArr = [];
    let mArr = [];
    let mov = [];
    membersData.forEach(z =&gt; {
        let newMember = {
            _id: z._id,
            Name: z.Name,
            Email: z.Email,
            City: z.City,
            Movies: mov
        }
        membersArr.push(newMember);
    })
    let ss = await subscriptionRest.getSubscriptions();
    let ssData = ss.data;

    if (ssData) {
        //   let result = await subscriptionBL.getAllSubscriptions();
        let result = await getSsForMembers(ssData, membersArr);
        console.log("result", result);

        if (result != "not found") {
            return result;
        } else {
            return membersArr;
        }
    } else {
        return membersArr;
    }

}

const getSsForMembers = async function(ss, mm) {
    let finalMmArr = {};
    Promise.all(ss.map(async x =&gt; {
        let found = mm.find(y =&gt; y._id == x.MemberID);
        if (found) {
            let memId = x.MemberID;
            let mem = await membersRest.getMember(memId);
            console.log("mem", memId);

            let memData = mem.data;
            memData.Movies = x.Movies
 let mArr = mm.filter(w =&gt; w._id != x.MemberID);
            mArr.push(memData);
            finalMmArr.data = mArr;
            console.log("finalMmArr", finalMmArr);
            return finalMmArr;
 else {
            return ("not found");
        }
    }))

}
</code></pre>
]]></description><link>https://tchumim.com/post/124350</link><guid isPermaLink="true">https://tchumim.com/post/124350</guid><dc:creator><![CDATA[שרה רחל]]></dc:creator><pubDate>Mon, 21 Jun 2021 10:38:19 GMT</pubDate></item></channel></rss>