{"id":329622,"date":"2022-02-15T21:00:41","date_gmt":"2022-02-15T21:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329622"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329622","title":{"rendered":"<span>\u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c async\/await \u0438 then\/catch \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"512\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/89d\/abd\/e77\/89dabde775948ee56249871064485de9.png\" data-width=\"1024\"\/><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0412 JavaScript \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430: Promise (ES6) \u0438 async \/ await (ES7). \u042d\u0442\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b \u0434\u0430\u044e\u0442 \u043d\u0430\u043c \u0440\u0430\u0432\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u043e \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u0432 callback hell! \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0422\u0438\u043c\u043e\u0444\u0435\u0435\u043c \u0422\u0438\u0443\u043d\u043e\u0432\u044b\u043c, \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043a\u0443\u0440\u0441\u0430 \u201cJavaScript\u201d \u0432 Skillbox.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432: <\/strong><em>\u201c\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0442\u0440\u0438, <\/em>\u2014<em> \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u0438. \u0421\u0443\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 addEventListener. \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JavaScript \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043d\u044f\u043b \u0441\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0430 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043e\u043d \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 Promise, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441 async\/await\u201d.\u00a0<\/em><\/p>\n<p>JavaScript \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439. \u041d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 API.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, JavaScript \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412 ES6 \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442 Promise, \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 then, catch \u0438 finally. \u0413\u043e\u0434 \u0441\u043f\u0443\u0441\u0442\u044f, \u0432 ES7, \u0432 \u044f\u0437\u044b\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u043e\u0434\u0445\u043e\u0434 \u0438 \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432\u0430: async \u0438 await.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u0442 \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 JavaScript; \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430\u044f \u0442\u0435\u043c\u0430: \u043a\u0430\u043a\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u2014 then \/ catch \/ finally \u0438\u043b\u0438 async \/ await \u2014 \u043b\u0443\u0447\u0448\u0435?<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432, \u0430\u0432\u0442\u043e\u0440 \u043a\u0443\u0440\u0441\u0430 \u201c<\/strong><a href=\"https:\/\/skillbox.ru\/course\/javascript\/\" rel=\"noopener noreferrer nofollow\"><strong><u>JavaScript<\/u><\/strong><\/a><strong>\u201d \u0432 Skillbox.:<\/strong> <em>\u201c\u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0447\u0435\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0410\u0432\u0442\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043b\u043e\u0436\u043d\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u043b\u0443\u0447\u0448\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a\u201d.<\/em><\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c.<\/p>\n<h2>then, catch \u0438 finally<\/h2>\n<p>then, catch \u0438 finally<strong> <\/strong>\u2014<strong> <\/strong>\u043c\u0435\u0442\u043e\u0434\u044b<strong> <\/strong>\u043e\u0431\u044a\u0435\u043a\u0442\u0430 Promise, \u043e\u043d\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438 \u0438\u0434\u0443\u0442 \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Promise.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 Promise:<\/p>\n<pre><code class=\"javascript\">const greeting = new Promise((resolve, reject) => {  \u00a0\u00a0resolve(\"Hello!\");  });<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f then, catch \u0438 finally \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0435\u0440\u0438\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d (then) \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d (cach) Promise. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a finally \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Promise, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u043e \u043b\u0438 \u043e\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u043e.<\/p>\n<pre><code class=\"javascript\">greeting  \u00a0\u00a0.then((value) => {  \u00a0\u00a0\u00a0 console.log(\"The Promise is resolved!\", value);  \u00a0\u00a0})  \u00a0\u00a0.catch((error) => {  \u00a0\u00a0\u00a0 console.error(\"The Promise is rejected!\", error);  \u00a0\u00a0})  \u00a0\u00a0.finally(() => {  \u00a0\u00a0\u00a0 console.log(\"The Promise is settled, meaning it has been resolved or rejected.\");  \u00a0\u00a0});<\/code><\/pre>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0441\u0430\u043c \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0432 catch \u043d\u0435 \u0432\u044b\u043a\u0438\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 throw \u0438\u043b\u0438 return Promise.reject, \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043d\u043e\u0432\u0430 \u043f\u0438\u0441\u0430\u0442\u044c then. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 finally \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0439\u201d.<\/em><\/p>\n<p>\u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0446\u0435\u043b\u044c\u044e \u0441\u0442\u0430\u0442\u044c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e then. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e then \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u043c Promise. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c then \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">fetch(url)  \u00a0\u00a0.then((response) => response.json())  \u00a0\u00a0.then((data) => {  \u00a0\u00a0\u00a0 return {  \u00a0\u00a0\u00a0\u00a0\u00a0 data: data,  \u00a0\u00a0\u00a0\u00a0\u00a0 status: response.status,  \u00a0\u00a0\u00a0 };  \u00a0\u00a0})  \u00a0\u00a0.then((res) => {  \u00a0\u00a0\u00a0 console.log(res.data, res.status);  \u00a0\u00a0});<\/code><\/pre>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u041a\u043e\u0434 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a response \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u201d.<\/em><\/p>\n<h2>async \u0438 await<\/h2>\n<p>async \u0438 await \u2014 \u044d\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 \u043f\u043e\u0432\u0435\u0440\u0445 Promise, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0430\u043a, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437 \u043e\u0434\u043d\u0430 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c.\u00a0<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e async \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043f\u0440\u0438 \u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <\/em>\u2014<em> await. await \u0436\u0435 \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f promise&#8217;\u0430 \u0438\u043b\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0439 async-\u0444\u0443\u043d\u043a\u0446\u0438\u0438\u201d.<\/em><\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 async \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u0438 \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043b\u0438 \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">async function doSomethingAsynchronous() {  \u00a0\u00a0\/\/ logic  }  const doSomethingAsynchronous = async () => {  \u00a0\u00a0\/\/ logic  };<\/code><\/pre>\n<p>await \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043b\u044e\u0431\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c Promise. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u201c\u0437\u0430\u0432\u0438\u0441\u043d\u0435\u0442\u201d \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441 greeting:<\/p>\n<pre><code class=\"javascript\">async function doSomethingAsynchronous() {  \u00a0\u00a0const value = await greeting;  }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e value \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0431\u044b \u043e\u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 try &#8230; catch &#8230; finally, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">async function doSomethingAsynchronous() {  \u00a0\u00a0try {  \u00a0\u00a0\u00a0 const value = await greeting;  \u00a0\u00a0\u00a0 console.log(\"The Promise is resolved!\", value);  \u00a0\u00a0} catch((error) {  \u00a0\u00a0\u00a0 console.error(\"The Promise is rejected!\", error);  \u00a0\u00a0} finally {  \u00a0\u00a0\u00a0 console.log(\"The Promise is settled, meaning it has been resolved or rejected.\");  \u00a0\u00a0}  }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f Promise \u0432 \u0440\u0430\u043c\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 async \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c await. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">async function getGreeting() {  \u00a0\u00a0return greeting;  }<\/code><\/pre>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 async \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0434\u0435 \u043a\u0430\u043a \u0431\u044b \u0435\u0441\u0442\u044c await, \u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f promise:<\/em><\/p>\n<pre><code class=\"javascript\">const res = await fetch(...);  return await res.json(); \/\/ \u0442\u0443\u0442 await \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c\u201d.<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430: \u0432\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c return await, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Promise, \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u043d\u044b\u0439 \u0432 \u0431\u043b\u043e\u043a\u0435 try &#8230; catch.<\/p>\n<pre><code class=\"javascript\">async function getGreeting() {  \u00a0\u00a0try {  \u00a0\u00a0\u00a0 return await greeting;  \u00a0\u00a0} catch (e) {  \u00a0\u00a0\u00a0 console.error(e);  \u00a0\u00a0}  }<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u043d\u043e \u0431\u0435\u0437 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u0434\u0438\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u043d\u0438\u0436\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432, \u043d\u0430\u043f\u0438\u0441\u0430\u0432\u0448\u0438\u0445 \u0431\u043e\u043b\u0435\u0435 10 \u043a\u043d\u0438\u0433, \u0432 \u043d\u0430\u0448\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u0431\u0438\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441 \u0442\u0440\u0435\u043c\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p><code>getAuthors<\/code> &#8212; returns all the authors in the database;<\/p>\n<\/li>\n<li>\n<p><code>getBooks<\/code> &#8212; returns all the books in the database;<\/p>\n<\/li>\n<li>\n<p><code>getBio<\/code> &#8212; returns the bio of a specific author.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p><code>Author: { id: \"3b4ab205\", name: \"Frank Herbert Jr.\", bioId: \"1138089a\" }<\/code><\/p>\n<\/li>\n<li>\n<p><code>Book: { id: \"e31f7b5e\", title: \"Dune\", authorId: \"3b4ab205\" }<\/code><\/p>\n<\/li>\n<li>\n<p><code>Bio: { id: \"1138089a\", description: \"Franklin Herbert Jr. was an American science-fiction author...\" }<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f filterProlificAuthors, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432\u0441\u0435 \u043a\u043d\u0438\u0433\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c 10 \u043a\u043d\u0438\u0433\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">function filterProlificAuthors(authors, books, minBookCount = 10) {  \u00a0\u00a0return authors.filter(  \u00a0\u00a0\u00a0 ({ id }) => books.filter(({ authorId }) => authorId === id).length > minBookCount  \u00a0\u00a0);  }<\/code><\/pre>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435\u00a0<\/h3>\n<h4>\u0427\u0430\u0441\u0442\u044c 1.<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u0432\u0441\u0435 \u043a\u043d\u0438\u0433\u0438, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0438\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u044d\u0442\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c. \u0412 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u0435 \u043d\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">FETCH all authors  FETCH all books  FILTER authors with more than 10 books  FOR each filtered author  FETCH the author\u2019s bio<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c FETCH, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443. \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0432 JavaScript? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0448\u0430\u0433\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f then:<\/p>\n<pre><code class=\"javascript\">getAuthors().then((authors) =>  \u00a0\u00a0getBooks()  \u00a0\u00a0\u00a0 .the((books) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0\u00a0\u00a0\u00a0 return Promise.all(prolificAuthorIds.map((id) => getBio(id)));  \u00a0\u00a0\u00a0 })  \u00a0\u00a0\u00a0 .then((bios) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Do something with the bios  \u00a0\u00a0\u00a0 })  );<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u041d\u043e \u0432\u043e\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u0434\u0430. \u0412\u0442\u043e\u0440\u043e\u0439 then \u0432\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 then, \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 then \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0435\u043d \u0432\u0442\u043e\u0440\u043e\u043c\u0443.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u042d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (\u043d\u0438\u0436\u0435). \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u043a\u043d\u0438\u0433 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0445\u043e\u0442\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b getAuthors\/Books \u0432 Promise.all, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0451\u0442 promise, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u0433\u043e promise&#8217;\u044b \u0442\u043e\u0436\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u0441\u044f.<\/em><\/p>\n<pre><code class=\"javascript\">Promise.all([  \u00a0\u00a0getAuthors(),  \u00a0\u00a0getBooks(),  ]).then(([authors, books]) => {  \u00a0\u00a0const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0return Promise.all(prolificAuthorIds.map((id) => getBio(id)));  }).then(bios => {  \u00a0\u00a0\/\/ \u2026  })\u201d<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0433 \u0431\u044b \u0441\u0442\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c then \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0434\u0430\u0436\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0442\u044c filterProlificAuthors \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 then, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"javascript\">getAuthors().then((authors) =>  \u00a0\u00a0getBooks()  \u00a0\u00a0\u00a0 .then((books) => filterProlificAuthors(authors, books))  \u00a0\u00a0\u00a0 .then((ids) => Promise.all(ids.map((id) => getBio(id))))  \u00a0\u00a0\u00a0 .then((bios) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Do something with the bios  \u00a0\u00a0\u00a0 })  );<\/code><\/pre>\n<p>\u0423 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e &#8212; \u043a\u0430\u0436\u0434\u044b\u0439 then \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. \u041f\u0440\u0430\u0432\u0434\u0430, \u0438 \u044d\u0442\u043e \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041d\u0443 \u0430 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 async \u0438 await? \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">async function getBios() {  \u00a0\u00a0const authors = await getAuthors();  \u00a0\u00a0const books = await getBooks();  \u00a0\u00a0const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0const bios = await Promise.all(prolificAuthorIds.map((id) => getBio(id)));  \u00a0\u00a0\/\/ Do something with the bios  }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0438 \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 async \/ await \u0441\u0442\u0430\u043d\u0443\u0442 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u0410 \u0432\u043e\u0442 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0440\u0435\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0412\u044b\u0437\u043e\u0432\u044b \u0441 await, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0434\u0443\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437, \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0445\u043e\u0442\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0417\u0434\u0435\u0441\u044c \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 promise&#8217;\u043e\u0432 \u0438 await:<\/em><\/p>\n<pre><code class=\"javascript\">const [authors, books] = await Promise.all([  getAuthors(),  getBooks(),  ]);\u201d<\/code><\/pre>\n<h4>\u0427\u0430\u0441\u0442\u044c 2<\/h4>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435. \u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 bios, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 bios, \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043d\u0438\u0433.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 async\/await:<\/p>\n<pre><code class=\"javascript\">async function getBios() {  \u00a0\u00a0const authors = await getAuthors();  \u00a0\u00a0const books = await getBooks();  \u00a0\u00a0const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0const bios = await Promise.all(prolificAuthorIds.map((id) => getBio(id)));  \u00a0\u00a0const result = {  \u00a0\u00a0\u00a0 bios,  \u00a0\u00a0\u00a0 totalAuthors: authors.length,  \u00a0\u00a0\u00a0 totalBooks: books.length,  \u00a0\u00a0};  }<\/code><\/pre>\n<p>\u041b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e. \u0421 \u043a\u043e\u0434\u043e\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c. \u0421\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u043e\u043d\u0446\u0435.<\/p>\n<p>\u0421 then \u044d\u0442\u043e \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e. \u0412 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 books \u0438 bios \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0443\u0440\u043e\u0432\u043d\u044f\u0445. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0435 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e books, \u043d\u043e \u044d\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0438\u043b\u043e \u0431\u044b \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u041e\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 &#8212; \u0432\u0432\u0435\u0441\u0442\u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"javascript\">getAuthors().then((authors) =>  \u00a0\u00a0getBooks().then((books) => {  \u00a0\u00a0\u00a0 const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0\u00a0 return Promise.all(prolificAuthorIds.map((id) => getBio(id))).then(  \u00a0\u00a0\u00a0\u00a0\u00a0 (bios) => {  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 const result = {  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 bios,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 totalAuthors: authors.length,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 totalBooks: books.length,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 };  \u00a0\u00a0\u00a0\u00a0\u00a0 }  \u00a0\u00a0\u00a0 );  \u00a0\u00a0})  );<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 books \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u044d\u0442\u0430\u043f\u0435:<\/p>\n<pre><code class=\"javascript\">getAuthors().then((authors) =>  \u00a0\u00a0getBooks()  \u00a0\u00a0\u00a0 .then((books) => [books, filterProlificAuthors(authors, books)])  \u00a0\u00a0\u00a0 .then(([books, ids]) =>  \u00a0\u00a0\u00a0\u00a0\u00a0 Promise.all([books, ...ids.map((id) => getBio(id))])  \u00a0\u00a0\u00a0 )  \u00a0\u00a0\u00a0 .then(([books, bios]) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 const result = {  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 bios,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 totalAuthors: authors.length,  \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 totalBooks: books.length,  \u00a0\u00a0\u00a0\u00a0\u00a0 };  \u00a0\u00a0\u00a0 })  );<\/code><\/pre>\n<p>\u041c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u044d\u0442\u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u043e \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c. \u0421\u043b\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u0434\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0438\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u0410 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043f\u0440\u044f\u043c \u043a\u043b\u0430\u0441\u0441\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0434\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e async\/await \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043a\u043e\u0434. \u0412 \u043a\u043e\u0434\u0435 \u043d\u0430 async\/await \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043a\u043d\u0446\u0438\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 promise&#8217;\u0430\u043c\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 then\/catch \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u043e\u0439, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, async\/await \u043c\u043e\u0436\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0440\u0443\u0447\u0438\u0442\u044c.\u201d<\/em><\/p>\n<h4>\u0427\u0430\u0441\u0442\u044c 3<\/h4>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0435\u0433\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Promise.all, \u0447\u0442\u043e \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0438 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u043a\u043d\u0438\u0433\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e.<\/p>\n<pre><code class=\"javascript\">Promise.all([getAuthors(), getBooks()]).then(([authors, books]) => {  \u00a0\u00a0const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0return Promise.all(prolificAuthorIds.map((id) => getBio(id))).then((bios) => {  \u00a0\u00a0\u00a0 const result = {  \u00a0\u00a0\u00a0\u00a0\u00a0 bios,  \u00a0\u00a0\u00a0\u00a0\u00a0 totalAuthors: authors.length,  \u00a0\u00a0\u00a0\u00a0\u00a0 totalBooks: books.length,  \u00a0\u00a0\u00a0 };  \u00a0\u00a0});  });<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f then. \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043d\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<pre><code class=\"javascript\">async function getBios() {    const [authors, books] = await Promise.all([getAuthors(), getBooks()]);    const prolificAuthorIds = filterProlificAuthors(authors, books);    const bios = await Promise.all(prolificAuthorIds.map((id) => getBio(id)));    const result = {      bios,      totalAuthors: authors.length,      totalBooks: books.length,    };  }<\/code><\/pre>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 chained then \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0443\u0442\u043e\u043c\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0414\u0430\u0436\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0442\u043e\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u043d \u0432\u044b\u0448\u0435, \u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0422\u0430\u043a, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043f\u044f\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e\u0441\u044c then, \u0438\u043c\u0435\u043b\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u044b \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, async \/ await \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0441\u0430\u043c\u043e\u0435 \u0443\u0434\u043e\u0431\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0447\u0430\u0441\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c\u0438, \u0447\u0435\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0434\u0435\u0441\u044c. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a async \/ await \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0443 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 then \u043c\u043e\u0436\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c \u043d\u0430\u0441 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e \u043f\u0443\u0442\u0438 \u043a callback hell \u2014 \u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u043a\u043e\u0431\u043e\u043a \u0438 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043d\u0435\u044f\u0441\u043d\u043e, \u0433\u0434\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0431\u043b\u043e\u043a \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432: <\/strong><em>\u201c\u0423\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u043b\u0443\u0447\u0448\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u2014 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0432\u044b\u0448\u0435. Promise \u0438 async\/await \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0438 \u0447\u0430\u0441\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0434\u043d\u043e, \u0430 \u043a\u043e\u0433\u0434\u0430 \u0434\u0440\u0443\u0433\u043e\u0435. \u0412\u044b \u0432\u043e\u043b\u044c\u043d\u044b \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u043e\u0431\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430. \u041d\u0438\u0436\u0435 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u0440\u0430\u0442\u043a\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430:\u00a0<\/em><\/p>\n<pre><code class=\"javascript\">\/\/ \u043d\u0430 await  const res = await fetch('...');  const json = await res.json();  \/\/ \u043d\u0430 promise + await  const json = await fetch('...').then(res => res.json());<\/code><\/pre>\n<p><em>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u0435\u0435.\u201d<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/651781\/\"> https:\/\/habr.com\/ru\/post\/651781\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u00a0\u0412 JavaScript \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430: Promise (ES6) \u0438 async \/ await (ES7). \u042d\u0442\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u044b \u0434\u0430\u044e\u0442 \u043d\u0430\u043c \u0440\u0430\u0432\u043d\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u043e \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c \u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0441 \u0432 callback hell! \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0422\u0438\u043c\u043e\u0444\u0435\u0435\u043c \u0422\u0438\u0443\u043d\u043e\u0432\u044b\u043c, \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043a\u0443\u0440\u0441\u0430 \u201cJavaScript\u201d \u0432 Skillbox.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432: <\/strong><em>\u201c\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0442\u0440\u0438, <\/em>\u2014<em> \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043a\u043e\u043b\u043b\u0431\u044d\u043a\u0438. \u0421\u0443\u0442\u044c \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 addEventListener. \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c JavaScript \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u0437\u0430\u043d\u044f\u043b \u0441\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0430 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043e\u043d \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0438 \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c \u044f\u0437\u044b\u043a\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 Promise, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441 async\/await\u201d.\u00a0<\/em><\/p>\n<p>JavaScript \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043a\u043e\u0434 \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439. \u041d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439. \u0418\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 API.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u043d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438, JavaScript \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0412 ES6 \u0431\u044b\u043b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043e\u0431\u044a\u0435\u043a\u0442 Promise, \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 then, catch \u0438 finally. \u0413\u043e\u0434 \u0441\u043f\u0443\u0441\u0442\u044f, \u0432 ES7, \u0432 \u044f\u0437\u044b\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u043e\u0434\u0445\u043e\u0434 \u0438 \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432\u0430: async \u0438 await.<\/p>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u0442 \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043b\u044c\u044e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 JavaScript; \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430\u044f \u0442\u0435\u043c\u0430: \u043a\u0430\u043a\u043e\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u2014 then \/ catch \/ finally \u0438\u043b\u0438 async \/ await \u2014 \u043b\u0443\u0447\u0448\u0435?<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432, \u0430\u0432\u0442\u043e\u0440 \u043a\u0443\u0440\u0441\u0430 \u201c<\/strong><a href=\"https:\/\/skillbox.ru\/course\/javascript\/\" rel=\"noopener noreferrer nofollow\"><strong><u>JavaScript<\/u><\/strong><\/a><strong>\u201d \u0432 Skillbox.:<\/strong> <em>\u201c\u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u043e\u0447\u0435\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0410\u0432\u0442\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043b\u043e\u0436\u043d\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043e\u0434\u0438\u043d \u043b\u0443\u0447\u0448\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a\u201d.<\/em><\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0433\u043b\u0430\u0432\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c.<\/p>\n<h2>then, catch \u0438 finally<\/h2>\n<p>then, catch \u0438 finally<strong> <\/strong>\u2014<strong> <\/strong>\u043c\u0435\u0442\u043e\u0434\u044b<strong> <\/strong>\u043e\u0431\u044a\u0435\u043a\u0442\u0430 Promise, \u043e\u043d\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0438 \u0438\u0434\u0443\u0442 \u043e\u0434\u0438\u043d \u0437\u0430 \u0434\u0440\u0443\u0433\u0438\u043c. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 Promise.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 Promise:<\/p>\n<pre><code class=\"javascript\">const greeting = new Promise((resolve, reject) => {  \u00a0\u00a0resolve(\"Hello!\");  });<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f then, catch \u0438 finally \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0435\u0440\u0438\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d (then) \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d (cach) Promise. \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u0430\u043a finally \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f Promise, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u043e \u043b\u0438 \u043e\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043e \u0438\u043b\u0438 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u043e.<\/p>\n<pre><code class=\"javascript\">greeting  \u00a0\u00a0.then((value) => {  \u00a0\u00a0\u00a0 console.log(\"The Promise is resolved!\", value);  \u00a0\u00a0})  \u00a0\u00a0.catch((error) => {  \u00a0\u00a0\u00a0 console.error(\"The Promise is rejected!\", error);  \u00a0\u00a0})  \u00a0\u00a0.finally(() => {  \u00a0\u00a0\u00a0 console.log(\"The Promise is settled, meaning it has been resolved or rejected.\");  \u00a0\u00a0});<\/code><\/pre>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u0435\u0441\u043b\u0438 \u0441\u0430\u043c \u043a\u043e\u043b\u043b\u0431\u044d\u043a \u0432 catch \u043d\u0435 \u0432\u044b\u043a\u0438\u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 throw \u0438\u043b\u0438 return Promise.reject, \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043d\u043e\u0432\u0430 \u043f\u0438\u0441\u0430\u0442\u044c then. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 finally \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0439\u201d.<\/em><\/p>\n<p>\u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0446\u0435\u043b\u044c\u044e \u0441\u0442\u0430\u0442\u044c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e then. \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e then \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u043c Promise. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c then \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">fetch(url)  \u00a0\u00a0.then((response) => response.json())  \u00a0\u00a0.then((data) => {  \u00a0\u00a0\u00a0 return {  \u00a0\u00a0\u00a0\u00a0\u00a0 data: data,  \u00a0\u00a0\u00a0\u00a0\u00a0 status: response.status,  \u00a0\u00a0\u00a0 };  \u00a0\u00a0})  \u00a0\u00a0.then((res) => {  \u00a0\u00a0\u00a0 console.log(res.data, res.status);  \u00a0\u00a0});<\/code><\/pre>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u041a\u043e\u0434 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a response \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d\u201d.<\/em><\/p>\n<h2>async \u0438 await<\/h2>\n<p>async \u0438 await \u2014 \u044d\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440 \u043f\u043e\u0432\u0435\u0440\u0445 Promise, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u0430\u043a, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437 \u043e\u0434\u043d\u0430 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u0439, \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u044c.\u00a0<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e async \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043f\u0440\u0438 \u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <\/em>\u2014<em> await. await \u0436\u0435 \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f promise&#8217;\u0430 \u0438\u043b\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0434\u0440\u0443\u0433\u043e\u0439 async-\u0444\u0443\u043d\u043a\u0446\u0438\u0438\u201d.<\/em><\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 async \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u0438 \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0438\u043b\u0438 \u0441\u0442\u0440\u0435\u043b\u043e\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">async function doSomethingAsynchronous() {  \u00a0\u00a0\/\/ logic  }  const doSomethingAsynchronous = async () => {  \u00a0\u00a0\/\/ logic  };<\/code><\/pre>\n<p>await \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043b\u044e\u0431\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c Promise. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u201c\u0437\u0430\u0432\u0438\u0441\u043d\u0435\u0442\u201d \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0434\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441 greeting:<\/p>\n<pre><code class=\"javascript\">async function doSomethingAsynchronous() {  \u00a0\u00a0const value = await greeting;  }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e value \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0431\u044b \u043e\u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 try &#8230; catch &#8230; finally, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">async function doSomethingAsynchronous() {  \u00a0\u00a0try {  \u00a0\u00a0\u00a0 const value = await greeting;  \u00a0\u00a0\u00a0 console.log(\"The Promise is resolved!\", value);  \u00a0\u00a0} catch((error) {  \u00a0\u00a0\u00a0 console.error(\"The Promise is rejected!\", error);  \u00a0\u00a0} finally {  \u00a0\u00a0\u00a0 console.log(\"The Promise is settled, meaning it has been resolved or rejected.\");  \u00a0\u00a0}  }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f Promise \u0432 \u0440\u0430\u043c\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 async \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c await. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">async function getGreeting() {  \u00a0\u00a0return greeting;  }<\/code><\/pre>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 async \u043d\u0435 \u043d\u0443\u0436\u0435\u043d. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0434\u0435 \u043a\u0430\u043a \u0431\u044b \u0435\u0441\u0442\u044c await, \u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f promise:<\/em><\/p>\n<pre><code class=\"javascript\">const res = await fetch(...);  return await res.json(); \/\/ \u0442\u0443\u0442 await \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c\u201d.<\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430: \u0432\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c return await, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c Promise, \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u043d\u044b\u0439 \u0432 \u0431\u043b\u043e\u043a\u0435 try &#8230; catch.<\/p>\n<pre><code class=\"javascript\">async function getGreeting() {  \u00a0\u00a0try {  \u00a0\u00a0\u00a0 return await greeting;  \u00a0\u00a0} catch (e) {  \u00a0\u00a0\u00a0 console.error(e);  \u00a0\u00a0}  }<\/code><\/pre>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u043d\u043e \u0431\u0435\u0437 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0441\u043e\u0437\u043d\u0430\u0442\u044c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u0434\u0438\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e.<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u043d\u0438\u0436\u043d\u043e\u0433\u043e \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432, \u043d\u0430\u043f\u0438\u0441\u0430\u0432\u0448\u0438\u0445 \u0431\u043e\u043b\u0435\u0435 10 \u043a\u043d\u0438\u0433, \u0432 \u043d\u0430\u0448\u0435\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0438\u0445 \u0431\u0438\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0441 \u0442\u0440\u0435\u043c\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p><code>getAuthors<\/code> &#8212; returns all the authors in the database;<\/p>\n<\/li>\n<li>\n<p><code>getBooks<\/code> &#8212; returns all the books in the database;<\/p>\n<\/li>\n<li>\n<p><code>getBio<\/code> &#8212; returns the bio of a specific author.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p><code>Author: { id: \"3b4ab205\", name: \"Frank Herbert Jr.\", bioId: \"1138089a\" }<\/code><\/p>\n<\/li>\n<li>\n<p><code>Book: { id: \"e31f7b5e\", title: \"Dune\", authorId: \"3b4ab205\" }<\/code><\/p>\n<\/li>\n<li>\n<p><code>Bio: { id: \"1138089a\", description: \"Franklin Herbert Jr. was an American science-fiction author...\" }<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f filterProlificAuthors, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432\u0441\u0435 \u043a\u043d\u0438\u0433\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0441 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c 10 \u043a\u043d\u0438\u0433\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">function filterProlificAuthors(authors, books, minBookCount = 10) {  \u00a0\u00a0return authors.filter(  \u00a0\u00a0\u00a0 ({ id }) => books.filter(({ authorId }) => authorId === id).length > minBookCount  \u00a0\u00a0);  }<\/code><\/pre>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435\u00a0<\/h3>\n<h4>\u0427\u0430\u0441\u0442\u044c 1.<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u0432\u0441\u0435 \u043a\u043d\u0438\u0433\u0438, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0438\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0441\u0435\u0445 \u0430\u0432\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u044d\u0442\u0438\u043c \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c. \u0412 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u0435 \u043d\u0430\u0448\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">FETCH all authors  FETCH all books  FILTER authors with more than 10 books  FOR each filtered author  FETCH the author\u2019s bio<\/code><\/pre>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c FETCH, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443. \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u044d\u0442\u043e \u0432 JavaScript? \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0448\u0430\u0433\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f then:<\/p>\n<pre><code class=\"javascript\">getAuthors().then((authors) =>  \u00a0\u00a0getBooks()  \u00a0\u00a0\u00a0 .the((books) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0\u00a0\u00a0\u00a0 return Promise.all(prolificAuthorIds.map((id) => getBio(id)));  \u00a0\u00a0\u00a0 })  \u00a0\u00a0\u00a0 .then((bios) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Do something with the bios  \u00a0\u00a0\u00a0 })  );<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u041d\u043e \u0432\u043e\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u0437\u0433\u043b\u044f\u0434\u0430. \u0412\u0442\u043e\u0440\u043e\u0439 then \u0432\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 then, \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 then \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0435\u043d \u0432\u0442\u043e\u0440\u043e\u043c\u0443.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u042d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a (\u043d\u0438\u0436\u0435). \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0432\u0442\u043e\u0440\u043e\u0432 \u0438 \u043a\u043d\u0438\u0433 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0445\u043e\u0442\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b getAuthors\/Books \u0432 Promise.all, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0435\u0440\u043d\u0451\u0442 promise, \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u0433\u043e promise&#8217;\u044b \u0442\u043e\u0436\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0442\u0441\u044f.<\/em><\/p>\n<pre><code class=\"javascript\">Promise.all([  \u00a0\u00a0getAuthors(),  \u00a0\u00a0getBooks(),  ]).then(([authors, books]) => {  \u00a0\u00a0const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0return Promise.all(prolificAuthorIds.map((id) => getBio(id)));  }).then(bios => {  \u00a0\u00a0\/\/ \u2026  })\u201d<\/code><\/pre>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0433 \u0431\u044b \u0441\u0442\u0430\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c then \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0434\u0430\u0436\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041c\u043e\u0436\u043d\u043e \u0434\u0430\u0442\u044c filterProlificAuthors \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 then, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"javascript\">getAuthors().then((authors) =>  \u00a0\u00a0getBooks()  \u00a0\u00a0\u00a0 .then((books) => filterProlificAuthors(authors, books))  \u00a0\u00a0\u00a0 .then((ids) => Promise.all(ids.map((id) => getBio(id))))  \u00a0\u00a0\u00a0 .then((bios) => {  \u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Do something with the bios  \u00a0\u00a0\u00a0 })  );<\/code><\/pre>\n<p>\u0423 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e &#8212; \u043a\u0430\u0436\u0434\u044b\u0439 then \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443. \u041f\u0440\u0430\u0432\u0434\u0430, \u0438 \u044d\u0442\u043e \u043d\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041d\u0443 \u0430 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 async \u0438 await? \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"javascript\">async function getBios() {  \u00a0\u00a0const authors = await getAuthors();  \u00a0\u00a0const books = await getBooks();  \u00a0\u00a0const prolificAuthorIds = filterProlificAuthors(authors, books);  \u00a0\u00a0const bios = await Promise.all(prolificAuthorIds.map((id) => getBio(id)));  \u00a0\u00a0\/\/ Do something with the bios  }<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0417\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0438 \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u043e \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 async \/ await \u0441\u0442\u0430\u043d\u0443\u0442 \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c\u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0435\u0432.<\/p>\n<p><strong>\u0422\u0438\u043c\u043e\u0444\u0435\u0439 \u0422\u0438\u0443\u043d\u043e\u0432:<\/strong> <em>\u201c\u0410 \u0432\u043e\u0442 \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0440\u0435\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0412\u044b\u0437\u043e\u0432\u044b \u0441 await, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0434\u0443\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437, \u0431\u0443\u0434\u0443\u0442<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-329622","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329622"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329622\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}