{"id":15950,"date":"2023-04-05T11:42:06","date_gmt":"2023-04-05T08:12:06","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/javascript-asyncawait-1ah7\/"},"modified":"2023-04-05T11:42:06","modified_gmt":"2023-04-05T08:12:06","slug":"javascript-asyncawait-1ah7","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/javascript-asyncawait-1ah7\/","title":{"rendered":"Javascript async\/wait &#8211; \u0627\u0646\u062c\u0645\u0646 DEV"},"content":{"rendered":"<div data-article-id=\"1426405\" id=\"article-body\">\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647\u060c \u0645\u0646 \u0628\u0647 \u0628\u062d\u062b \u062f\u0631 \u0645\u0648\u0631\u062f \u06a9\u062f\u0647\u0627\u06cc \u0646\u0627\u0647\u0645\u0632\u0645\u0627\u0646 \u0648 \u0628\u0647 \u0637\u0648\u0631 \u062e\u0627\u0635 \u062a\u0631 \u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait \u0627\u062f\u0627\u0645\u0647 \u062e\u0648\u0627\u0647\u0645 \u062f\u0627\u062f.<\/p>\n<p>\u0642\u0628\u0644 \u0627\u0632 \u0631\u0641\u062a\u0646 \u0628\u06cc\u0634\u062a\u0631\u060c \u0627\u06af\u0631 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u0645 \u06cc\u06a9 \u0686\u06cc\u0632 \u0631\u0627 \u0627\u0632 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u062d\u0630\u0641 \u06a9\u0646\u06cc\u062f \u0627\u06cc\u0646 \u0627\u0633\u062a: \u062f\u0631 \u067e\u0627\u06cc\u0627\u0646 \u0631\u0648\u0632\u060c async\/wait \u0628\u0647 \u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u062a\u0627 \u06a9\u062f\u0647\u0627\u06cc \u0647\u0645\u06af\u0627\u0645\u200c\u0633\u0627\u0632\u06cc \u0631\u0627 \u0628\u0647\u200c\u062c\u0627\u06cc \u062a\u0648\u062f\u0631\u062a\u0648\u06cc \u0628\u06cc\u200c\u067e\u0627\u06cc\u0627\u0646 \u062a\u0645\u0627\u0633\u200c\u0647\u0627\u06cc \u0628\u0631\u06af\u0634\u062a\u06cc\u060c \u0628\u0647 \u0635\u0648\u0631\u062a \u0647\u0645\u0632\u0645\u0627\u0646 \u0628\u0646\u0648\u06cc\u0633\u06cc\u0645.<\/p>\n<p><strong>\u0646\u06a9\u0627\u062a \u0627\u0635\u0644\u06cc<\/strong><\/p>\n<p>1. \u0647\u0646\u06af\u0627\u0645\u06cc \u06a9\u0647 \u0627\u0632 async\/wait \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u06cc\u0645\u060c \u0627\u0646\u062a\u0638\u0627\u0631 \u0647\u0645\u06cc\u0634\u0647 \u0645\u0646\u062a\u0638\u0631 \u0645\u06cc \u0645\u0627\u0646\u062f \u062a\u0627 \u0648\u0639\u062f\u0647 \u062d\u0644 \u0634\u0648\u062f.<\/p>\n<p>2. \u0645\u0627 \u0641\u0642\u0637 \u0632\u0645\u0627\u0646\u06cc \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u0627\u0632 await \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u0645 \u06a9\u0647 \u062f\u0631 \u062c\u0644\u0648\u06cc \u062a\u0627\u0628\u0639\u060c async \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u0645\u060c \u0627\u06cc\u0646 \u0645\u0647\u0645 \u0627\u0633\u062a\u060c \u0632\u06cc\u0631\u0627 \u0627\u063a\u0644\u0628 \u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u0627\u0641\u0631\u0627\u062f async\/wait \u0631\u0627 \u06cc\u0627\u062f \u0645\u06cc\u200c\u06af\u06cc\u0631\u0646\u062f\u060c \u0645\u062e\u0635\u0648\u0635\u0627\u064b \u0645\u0628\u062a\u062f\u06cc\u0627\u0646\u060c \u062a\u0642\u0631\u06cc\u0628\u0627\u064b \u0634\u0631\u0648\u0639 \u0628\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 await \u062f\u0631 \u0633\u0631\u0627\u0633\u0631 \u06a9\u062f \u062e\u0648\u062f \u0645\u06cc\u200c\u06a9\u0646\u0646\u062f \u0648 \u0634\u0645\u0627 \u0646\u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u062f. .  \u0641\u0642\u0637 \u062f\u0631 \u0635\u0648\u0631\u062a\u06cc \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0627\u0646\u062a\u0638\u0627\u0631 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f \u06a9\u0647 \u0639\u0645\u0644\u06a9\u0631\u062f\u06cc \u06a9\u0647 \u062a\u0646\u0638\u06cc\u0645 \u06a9\u0631\u062f\u0647\u200c\u0627\u06cc\u062f \u0648\u0627\u0642\u0639\u0627\u064b \u0646\u0627\u0647\u0645\u06af\u0627\u0645 \u0628\u0627\u0634\u062f.<\/p>\n<p>\u062a\u0627\u0628\u0639 3.async \u0647\u0645\u06cc\u0634\u0647 \u06cc\u06a9 \u0648\u0639\u062f\u0647 \u0631\u0627 \u0628\u0631\u0645\u06cc \u06af\u0631\u062f\u0627\u0646\u062f.<\/p>\n<p><strong>NB<\/strong>: \u062f\u0631 \u0637\u0648\u0644 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647\u060c \u0645\u0646 \u0627\u0632 \u062a\u0627\u0628\u0639 arrow \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u062e\u0648\u0627\u0647\u0645 \u06a9\u0631\u062f\u060c \u0627\u0645\u0627 \u0627\u06af\u0631 \u062a\u0631\u062c\u06cc\u062d \u0645\u06cc \u062f\u0647\u06cc\u062f \u0627\u0632 \u062a\u0627\u0628\u0639 \u0633\u0646\u062a\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f\u060c \u0647\u06cc\u0686 \u0642\u0627\u0646\u0648\u0646\u06cc \u0639\u0644\u06cc\u0647 \u0634\u0645\u0627 \u0648\u062c\u0648\u062f \u0646\u062f\u0627\u0631\u062f\u060c \u0641\u0642\u0637 \u0622\u0646 \u0631\u0627 \u062f\u0646\u0628\u0627\u0644 \u06a9\u0646\u06cc\u062f.<\/p>\n<p><strong>\u0645\u062b\u0627\u0644 \u06a9\u0644\u06cc<\/strong><\/p>\n<p><em>\/\/\u0646\u0645\u0627\u06cc\u0634 \u0646\u062d\u0648\u0647 \u0639\u0645\u0644\u06a9\u0631\u062f async \u0647\u0645\u06cc\u0634\u0647 \u06cc\u06a9 \u0648\u0639\u062f\u0647 \u0631\u0627 \u0628\u0631\u0645\u06cc \u06af\u0631\u062f\u0627\u0646\u062f<\/em><\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const example = async ()=&gt; {\n    return \"Hello world\"\n}\nconsole.log(example()) \/\/ it will show a promise in the console.\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<br \/><br \/>\u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0645\u06cc \u0628\u06cc\u0646\u06cc\u062f\u060c \u0627\u06cc\u0646 \u06cc\u06a9 \u0648\u0639\u062f\u0647 \u0627\u0633\u062a \u0648 \u0628\u0644\u0627\u0641\u0627\u0635\u0644\u0647 \u0645\u062d\u0642\u0642 \u0645\u06cc \u0634\u0648\u062f.  \u0641\u0642\u0637 \u0628\u0647 \u062e\u0627\u0637\u0631 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u06a9\u0647 async \u0647\u0645\u06cc\u0634\u0647 \u0648 \u0647\u0645\u06cc\u0634\u0647 \u06cc\u06a9 \u0648\u0639\u062f\u0647 \u0631\u0627 \u0628\u0631\u0645\u06cc\u200c\u06af\u0631\u062f\u0627\u0646\u062f.<\/p>\n<p><em>\/\/\u0646\u0645\u0627\u06cc\u0634 \u0646\u062d\u0648\u0647 \u0639\u0645\u0644\u06a9\u0631\u062f await:<\/em><\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const example = async () =&gt;{\n    return \"Hello world\";\n}\nconst someFunc = async () =&gt;{\n    const result = await example();\n    console.log(result);\n}\nsomeFunc();\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<br \/><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682324_32_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 2\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><br \/>\u0627\u0632 \u0627\u06cc\u0646\u062c\u0627\u060c await \u0628\u0627\u06cc\u062f \u0645\u0646\u062a\u0638\u0631 \u0628\u0645\u0627\u0646\u06cc\u062f \u062a\u0627 \u0648\u0639\u062f\u0647 \u062a\u0627\u0628\u0639 \u0645\u062b\u0627\u0644 \u062d\u0644 \u0634\u0648\u062f\u060c \u0633\u067e\u0633 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0646\u062a\u06cc\u062c\u0647 \u0631\u0627 \u062f\u0631 \u06a9\u0646\u0633\u0648\u0644 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f.  \u0627\u06cc\u0646 \u0628\u0633\u06cc\u0627\u0631 \u0645\u0647\u0645 \u0627\u0633\u062a \u0632\u06cc\u0631\u0627 \u0645\u062c\u0628\u0648\u0631 \u0646\u06cc\u0633\u062a\u06cc\u062f \u0628\u0647 \u062c\u0627\u06cc \u0622\u0646 \u0627\u0632 \u0632\u0646\u062c\u06cc\u0631\u0647 \u0647\u0627\u06cc .then() \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f\u060c \u0628\u0627\u06cc\u062f \u0645\u0646\u062a\u0638\u0631 \u0628\u0645\u0627\u0646\u06cc\u062f \u062a\u0627 \u0648\u0639\u062f\u0647 \u062d\u0644 \u0634\u0648\u062f \u0648 \u0646\u062a\u06cc\u062c\u0647 \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f.<\/p>\n<p><strong>\u0645\u062b\u0627\u0644 \u062f\u0646\u06cc\u0627\u06cc \u0648\u0627\u0642\u0639\u06cc:<\/strong><\/p>\n<p>\u0645\u0639\u0645\u0648\u0644\u0627\u064b\u060c \u0634\u0645\u0627 \u0645\u0639\u0645\u0648\u0644\u0627\u064b \u0645\u0646\u0627\u0628\u0639 \u0631\u0627 \u0627\u0632 \u0637\u0631\u06cc\u0642 \u0633\u06cc\u0645 \u062f\u0631\u062e\u0648\u0627\u0633\u062a \u0645\u06cc\u200c\u06a9\u0646\u06cc\u062f\u060c \u06cc\u0639\u0646\u06cc \u0627\u0632 \u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647\u060c API \u06cc\u0627 \u0647\u0631 \u0686\u06cc\u0632 \u062f\u06cc\u06af\u0631\u06cc\u060c \u0627\u0645\u0627 \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0645\u0646 \u0627\u0632 \u06cc\u06a9 \u0645\u062b\u0627\u0644 \u0633\u0627\u062f\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u0645 \u06a9\u0647 \u062f\u0631 \u0622\u0646 \u0622\u0631\u0627\u06cc\u0647 \u06a9\u0627\u0631\u0628\u0631 (\u0634\u0627\u0645\u0644 \u062f\u0627\u0646\u0634\u062c\u0648\u06cc\u0627\u0646) \u0648 \u0622\u0631\u0627\u06cc\u0647 \u06a9\u0644\u0627\u0633\u200c\u0647\u0627 (\u0634\u0627\u0645\u0644 \u0645\u0648\u0636\u0648\u0639\u0627\u062a) \u062f\u0627\u0646\u0634\u200c\u0622\u0645\u0648\u0632\u0627\u0646 \u0647\u0633\u062a\u0646\u062f. \u06af\u0631\u0641\u062a\u0646<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const users = [ \/\/ array of objects containing stundets and their ID\n    {id: 1, name:\"kebean\"},\n    {id: 2, name:\"Chico\"},\n    {id:3, name:\"Maelle\"},\n]\nconst classes = [ \/\/ array of objects containing student ID and classes they are taking\n    {studentId:1, classesTaken:[\"OOP\", \"C\", \".Net\"]}, \/\/kebean take this class because the ID matches \n    {studentId:2, classesTaken:[\"Math\", \"History\"]}, \/\/Chico take this class because the ID mathches\n    {studentId:3, classesTaken:[\"Physics\", \"Chemistry\", \"Geography\"]} \/\/Maelle take this class because the ID mathches\n]\n\nconst getUser = (name) =&gt;{\n    return new Promise((resolve, reject) =&gt;{\n        const user = users.find((user) =&gt; user.name ===name);\n        if (user){\n            return resolve(user);\n        }else{\n            reject(`No such user with name: ${name}`);\n        }\n    })\n}\n\nconst getClasses = studentId =&gt; {\n    return new Promise((resolve, reject) =&gt;{\n        const userClasses = classes.find((user) =&gt; user.studentId === studentId)\n        if(userClasses){\n            return resolve(userClasses.classesTaken)\n        }else{\n            reject(\"Wrong ID\")\n        }\n    })\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>NB<\/strong>: \u0628\u0627\u06cc\u062f \u062f\u0631\u06a9 \u06a9\u0646\u06cc\u062f \u06a9\u0647 \u062a\u0648\u0627\u0628\u0639 \u0628\u0627\u0644\u0627 \u0628\u0647 \u062a\u0631\u062a\u06cc\u0628 \u0627\u062a\u0641\u0627\u0642 \u0645\u06cc \u0627\u0641\u062a\u0646\u062f\u060c \u062a\u0646\u0647\u0627 \u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u062f\u0627\u0646\u0634 \u0622\u0645\u0648\u0632 \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f\u060c \u062a\u0646\u0647\u0627 \u062f\u0631 \u0627\u06cc\u0646 \u0635\u0648\u0631\u062a \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647 \u0645\u0648\u0636\u0648\u0639\u06cc \u06a9\u0647 \u062f\u0631 \u062d\u0627\u0644 \u0645\u0637\u0627\u0644\u0639\u0647 \u0627\u0633\u062a \u062f\u0633\u062a\u0631\u0633\u06cc \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f.<\/p>\n<p>\u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0628\u0627 \u062f\u0648 \u062a\u0627\u0628\u0639 \u0628\u0627\u0644\u0627 \u0622\u0634\u0646\u0627 \u0647\u0633\u062a\u06cc\u062f\u060c \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u0645 \u0646\u0634\u0627\u0646 \u062f\u0647\u0645 \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0627\u062f\u0647\u200c\u0647\u0627 \u0631\u0627 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u0634 .then() \u0645\u0639\u0645\u0648\u0644\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f \u0648 \u0628\u0639\u062f\u0627\u064b \u0646\u0634\u0627\u0646 \u062e\u0648\u0627\u0647\u0645 \u062f\u0627\u062f \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u062f\u0631 \u062d\u06cc\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait \u06a9\u0647 \u0645\u0624\u062b\u0631\u062a\u0631 \u0627\u0633\u062a\u060c \u0628\u0647 \u0647\u0645\u0627\u0646 \u0686\u06cc\u0632\u06cc \u062f\u0633\u062a \u067e\u06cc\u062f\u0627 \u06a9\u0646\u06cc\u062f. \u062d\u062f\u0627\u0642\u0644 \u0627\u0632 \u0646\u0638\u0631 \u0645\u0646 \u0642\u0627\u0628\u0644 \u062e\u0648\u0627\u0646\u062f\u0646 \u0627\u0633\u062a<\/p>\n<p><em>\u0631\u0648\u06cc\u06a9\u0631\u062f .then() \u0645\u0639\u0645\u0648\u0644\u06cc<\/em><\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>getUser(\"kebean\") \/\/ returns a promise\n.then((user) =&gt; console.log(user)) \/\/you will have access to data you pass into resolve()\n.catch((error) =&gt; console.log(error)) \/\/when there is errors, you will catch them here\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0645\u0646\u0637\u0642 \u0628\u0647 \u0627\u06cc\u0646 \u0635\u0648\u0631\u062a \u0627\u0633\u062a: \u0627\u06af\u0631 \u0646\u0627\u0645 \u0645\u0637\u0627\u0628\u0642\u062a \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u0646\u0627\u0645 \u0631\u0627 \u067e\u0627\u0633 \u0645\u06cc \u06a9\u0646\u06cc\u062f\u060c \u0627\u0644\u0628\u062a\u0647 \u062f\u0627\u0646\u0634 \u0622\u0645\u0648\u0632 \u0631\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u06cc \u06a9\u0646\u06cc\u062f \u0648 \u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u0646\u0627\u0645 \u0645\u0637\u0627\u0628\u0642\u062a \u0646\u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u062f\u060c \u0628\u0627 \u067e\u06cc\u063a\u0627\u0645 \u062e\u0637\u0627 \u0645\u0648\u0627\u062c\u0647 \u0645\u06cc \u0634\u0648\u06cc\u062f.<br \/>\u062e\u0631\u0648\u062c\u06cc:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682325_518_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 3\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><\/p>\n<p>\u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u06a9\u0627\u0631\u0628\u0631 \u0648\u062c\u0648\u062f \u0646\u062f\u0627\u0631\u062f:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>getUser(\"kebeans\") \n.then((user) =&gt; console.log(user)) \n.catch((error) =&gt; console.log(error)) \n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0645\u0634\u0627\u0647\u062f\u0647 \u0645\u06cc \u06a9\u0646\u06cc\u062f \u067e\u06cc\u063a\u0627\u0645 \u062e\u0637\u0627 \u0646\u0645\u0627\u06cc\u0634 \u062f\u0627\u062f\u0647 \u0645\u06cc \u0634\u0648\u062f<br \/>\u062e\u0631\u0648\u062c\u06cc:<br \/><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682325_370_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 4\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>getUser(\"kebean\") \n.then((user) =&gt; getClasses(user.id)) \/\/invoking getClasses and pass in the user ID\n.then((classes) =&gt; console.log(classes)) \/\/the getClasses function above, returns classes that match to the user ID or student ID you passed in\n.catch((error) =&gt; console.log(error)) \n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<br \/><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682325_853_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 4\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><\/p>\n<p>\u0645\u0634\u06a9\u0644 \u0631\u0627\u0647\u200c\u0627\u0646\u062f\u0627\u0632\u06cc \u0628\u0627\u0644\u0627 \u0627\u06cc\u0646 \u0627\u0633\u062a \u06a9\u0647 \u0648\u0642\u062a\u06cc \u0686\u0646\u062f\u06cc\u0646 \u0639\u0645\u0644\u06cc\u0627\u062a async \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f\u060c \u0628\u0627\u06cc\u062f \u0627\u06cc\u0646 .then() \u0631\u0627 \u0632\u0646\u062c\u06cc\u0631\u0647\u200c\u0627\u06cc \u06a9\u0646\u06cc\u062f \u06a9\u0647 \u062e\u0648\u0627\u0646\u062f\u0646\u06cc \u0646\u06cc\u0633\u062a \u0648 \u0646\u0648\u0634\u062a\u0646 \u0637\u0648\u0644\u0627\u0646\u06cc \u0627\u0633\u062a.  \u0627\u06cc\u0646\u062c\u0627\u0633\u062a \u06a9\u0647 async\/wait \u0648\u0627\u0642\u0639\u0627\u064b \u0645\u06cc \u062f\u0631\u062e\u0634\u062f\u060c \u0632\u06cc\u0631\u0627 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u06a9\u062f \u0628\u0627\u0644\u0627 \u0631\u0627 \u0628\u0627 \u062a\u0646\u0638\u06cc\u0645 \u0645\u062c\u062f\u062f \u06a9\u062f \u0628\u0631\u0627\u06cc \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/await \u062e\u0648\u0627\u0646\u0627\u062a\u0631 \u06a9\u0646\u06cc\u062f.<\/p>\n<p><em>\u0631\u0648\u06cc\u06a9\u0631\u062f async\/wait<\/em><\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const getStudent = async () =&gt;{\n    const user = await getUser(\"kebean\") \n    console.log(user)\n}\ngetStudent()\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<br \/><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682325_301_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 5\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><\/p>\n<p>\u0627\u0632 \u0645\u062b\u0627\u0644 \u0628\u0627\u0644\u0627\u060c \u0645\u06cc \u0628\u06cc\u0646\u06cc\u062f \u06a9\u0647 \u062f\u0633\u062a\u0631\u0633\u06cc \u0628\u0647 \u062f\u0627\u0646\u0634 \u0622\u0645\u0648\u0632 \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait \u0627\u0645\u06a9\u0627\u0646 \u067e\u0630\u06cc\u0631 \u0627\u0633\u062a.  \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0628\u0628\u06cc\u0646\u06cc\u0645 \u0686\u06af\u0648\u0646\u0647 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0628\u0647 \u06a9\u0644\u0627\u0633\u200c\u0647\u0627\u06cc\u06cc \u06a9\u0647 \u062f\u0627\u0646\u0634\u200c\u0622\u0645\u0648\u0632 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u062f \u062f\u0631 \u0622\u0646 \u0634\u0631\u06a9\u062a \u06a9\u0646\u062f\u060c \u062f\u0633\u062a\u0631\u0633\u06cc \u067e\u06cc\u062f\u0627 \u06a9\u0631\u062f.<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const getStudent = async () =&gt;{\n    const user = await getUser(\"kebean\");\n    if(user){\n        const classes = await getClasses(user.id);\n        console.log(classes)\n    }\n}\ngetStudent()\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<br \/><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682325_640_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 6\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><\/p>\n<p>\u0631\u0648\u0646\u0642!!  \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u06a9\u0644\u0627\u0633 \u0647\u0627\u06cc\u06cc \u0631\u0627 \u06a9\u0647 kebean \u0645\u06cc \u06af\u0630\u0631\u0627\u0646\u062f \u0646\u06cc\u0632 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u0641\u0642\u0637 \u0646\u06af\u0627\u0647\u06cc \u0628\u0647 \u06a9\u062f \u062f\u0631 \u0647\u0631 \u062f\u0648 \u0631\u0648\u06cc\u06a9\u0631\u062f \u0628\u06cc\u0646\u062f\u0627\u0632\u06cc\u062f\u060c \u0645\u0646\u0638\u0648\u0631\u0645 \u0627\u06cc\u0646 \u0627\u0633\u062a \u06a9\u0647 \u062d\u062a\u06cc \u0627\u06af\u0631 \u06a9\u062f \u062a\u0642\u0631\u06cc\u0628\u0627\u064b \u06cc\u06a9 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u0645\u06cc\u200c\u062f\u0647\u062f\u060c \u0628\u0647 \u0648\u0636\u0648\u062d \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0628\u06cc\u0646\u06cc\u062f \u06a9\u0647 \u0631\u0648\u06cc\u06a9\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait \u0628\u0633\u06cc\u0627\u0631 \u062e\u0648\u0627\u0646\u0627\u062a\u0631 \u0648 \u06a9\u0648\u062a\u0627\u0647\u200c\u062a\u0631 \u0627\u0633\u062a.<\/p>\n<p><strong>\u0646\u062d\u0648\u0647 \u0631\u0633\u06cc\u062f\u06af\u06cc \u0628\u0647 \u062e\u0637\u0627\u0647\u0627 \u0647\u0646\u06af\u0627\u0645 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait<\/strong><\/p>\n<p>\u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0645\u06cc \u0628\u06cc\u0646\u06cc\u062f\u060c \u0647\u0646\u06af\u0627\u0645 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait \u0646\u0645\u06cc \u062a\u0648\u0627\u0646 \u0622\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0627\u0646\u062a\u0638\u0627\u0631 \u0645\u06cc \u0631\u0648\u062f\u060c \u0628\u0627 \u062e\u0637\u0627 \u0628\u0631\u062e\u0648\u0631\u062f \u06a9\u0631\u062f.  \u0628\u0647 \u06a9\u062f \u0632\u06cc\u0631 \u062f\u0642\u062a \u06a9\u0646\u06cc\u062f:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const getStudent = async () =&gt;{\n    const user = await getUser(\"kebeans\");\n    if(user){\n        const classes = await getClasses(user.id);\n        console.log(classes)\n    }\n}\ngetStudent()\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<br \/><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682326_342_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 7\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><br \/>\u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0645\u06cc \u0628\u06cc\u0646\u06cc\u062f\u060c student(user) &#8220;kebeans&#8221; (\u0628\u0627 &#8220;s&#8221; \u062f\u0631 \u0627\u0646\u062a\u0647\u0627) \u0648\u062c\u0648\u062f \u0646\u062f\u0627\u0631\u062f \u0648 \u0628\u0647 \u062c\u0627\u06cc \u062f\u0631\u06cc\u0627\u0641\u062a \u067e\u06cc\u063a\u0627\u0645 \u062e\u0637\u0627\u06cc \u062a\u0639\u0631\u06cc\u0641 \u0634\u062f\u0647 \u062f\u0631 reject()\u060c \u062f\u0631 \u06a9\u0646\u0633\u0648\u0644 \u0648 \u0622\u0646\u0686\u0647 \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u06cc\u062f \u0622\u0634\u0641\u062a\u0647 \u0645\u06cc \u0634\u0648\u06cc\u062f. \u0627\u06cc\u0646 \u0627\u0633\u062a \u06a9\u0647 \u0622\u0646 \u0631\u0627 \u0628\u0627 \u0638\u0631\u0627\u0641\u062a \u0627\u062f\u0627\u0631\u0647 \u06a9\u0646\u06cc\u0645.  \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0628\u0627 \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0628\u0644\u0648\u06a9 try and catch \u0645\u0627\u0646\u0646\u062f \u0632\u06cc\u0631 \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u062f:<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>const getStudent = async () =&gt;{\n    try {\n        const user = await getUser(\"kebeans\");\n        if(user){\n            const classes = await getClasses(user.id);\n            console.log(classes)\n        }\n    } catch (error) {\n        console.log(error)\n    }\n}\ngetStudent()\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u062e\u0631\u0648\u062c\u06cc:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nabfollower.com\/blog\/wp-content\/uploads\/2023\/04\/1680682326_653_Javascript-asyncwait-\u0627\u0646\u062c\u0645\u0646-DEV.png\" alt=\"\u062a\u0635\u0648\u06cc\u0631 8\" loading=\"lazy\" width=\"880\" height=\"495\" title=\"\"><\/p>\n<p><strong>\u0646\u062a\u06cc\u062c\u0647<\/strong><\/p>\n<p>\u0627\u0645\u06cc\u062f\u0648\u0627\u0631\u06cc\u0645\u060c \u0627\u06a9\u0646\u0648\u0646 \u0628\u0647 \u0648\u0636\u0648\u062d \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0628\u06cc\u0646\u06cc\u062f \u06a9\u0647 \u0686\u0631\u0627 \u0647\u0646\u06af\u0627\u0645 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u0627\u0646\u062c\u0627\u0645 \u0648\u0638\u0627\u06cc\u0641 \u0646\u0627\u0647\u0645\u0632\u0645\u0627\u0646\u060c async\/wait \u062a\u0642\u0631\u06cc\u0628\u0627\u064b \u0628\u0647 \u0627\u0628\u0632\u0627\u0631\u06cc \u062a\u0628\u062f\u06cc\u0644 \u0634\u062f\u0647 \u0627\u0633\u062a.<\/p>\n<p>\u0627\u06cc\u0646 \u062e\u0648\u0627\u0646\u0627\u06cc\u06cc \u0631\u0627 \u0628\u0627 \u0627\u062c\u0627\u0632\u0647 \u062f\u0627\u062f\u0646 \u0628\u0647 \u0645\u0627 \u0628\u0631\u0627\u06cc \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f\u0647\u0627\u06cc \u0646\u0627\u0647\u0645\u0632\u0645\u0627\u0646 \u0628\u0647 \u0633\u0628\u06a9 \u0647\u0645\u06af\u0627\u0645\u200c\u062a\u0631 \u0628\u0647\u0628\u0648\u062f \u0645\u06cc\u200c\u0628\u062e\u0634\u062f \u0648 \u062e\u0648\u0627\u0646\u062f\u0646 \u0648 \u062f\u0631\u06a9 \u0622\u0646 \u0631\u0627 \u0622\u0633\u0627\u0646\u200c\u062a\u0631 \u0645\u06cc\u200c\u06a9\u0646\u062f.  \u0627\u06cc\u0646 \u0647\u0645\u0686\u0646\u06cc\u0646 \u0645\u06cc \u062a\u0648\u0627\u0646\u062f \u0628\u0647 \u0648\u06cc\u0698\u0647 \u0628\u0631\u0627\u06cc \u062a\u0648\u0633\u0639\u0647 \u062f\u0647\u0646\u062f\u06af\u0627\u0646\u06cc \u06a9\u0647 \u062f\u0631 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0646\u0627\u0647\u0645\u0632\u0645\u0627\u0646 \u062a\u0627\u0632\u0647 \u06a9\u0627\u0631 \u0647\u0633\u062a\u0646\u062f \u0645\u0641\u06cc\u062f \u0628\u0627\u0634\u062f.<\/p>\n<p>\u0628\u0627 \u062a\u0634\u06a9\u0631 \u0627\u0632 \u062e\u0648\u0627\u0646\u062f\u0646 \u0648 \u06a9\u062f \u0646\u0648\u06cc\u0633\u06cc \u062e\u0648\u0634\u062d\u0627\u0644!<\/p>\n<p>\u0633\u0641\u0627\u0631\u0634\u06cc.<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647\u060c \u0645\u0646 \u0628\u0647 \u0628\u062d\u062b \u062f\u0631 \u0645\u0648\u0631\u062f \u06a9\u062f\u0647\u0627\u06cc \u0646\u0627\u0647\u0645\u0632\u0645\u0627\u0646 \u0648 \u0628\u0647 \u0637\u0648\u0631 \u062e\u0627\u0635 \u062a\u0631 \u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 async\/wait \u0627\u062f\u0627\u0645\u0647 \u062e\u0648\u0627\u0647\u0645 \u062f\u0627\u062f. \u0642\u0628\u0644 \u0627\u0632 \u0631\u0641\u062a\u0646 \u0628\u06cc\u0634\u062a\u0631\u060c \u0627\u06af\u0631 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u0645 \u06cc\u06a9 \u0686\u06cc\u0632 \u0631\u0627 \u0627\u0632 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u062d\u0630\u0641 \u06a9\u0646\u06cc\u062f \u0627\u06cc\u0646 \u0627\u0633\u062a: \u062f\u0631 \u067e\u0627\u06cc\u0627\u0646 \u0631\u0648\u0632\u060c async\/wait \u0628\u0647 \u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u062a\u0627 \u06a9\u062f\u0647\u0627\u06cc \u0647\u0645\u06af\u0627\u0645\u200c\u0633\u0627\u0632\u06cc \u0631\u0627 \u0628\u0647\u200c\u062c\u0627\u06cc \u062a\u0648\u062f\u0631\u062a\u0648\u06cc \u0628\u06cc\u200c\u067e\u0627\u06cc\u0627\u0646 \u062a\u0645\u0627\u0633\u200c\u0647\u0627\u06cc \u0628\u0631\u06af\u0634\u062a\u06cc\u060c &hellip;<\/p>\n","protected":false},"author":2,"featured_media":15951,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-15950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/15950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=15950"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/15950\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/15951"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=15950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=15950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=15950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}