{"id":1272,"date":"2022-06-12T19:34:40","date_gmt":"2022-06-12T11:34:40","guid":{"rendered":"http:\/\/zhuxinyong.com\/?p=1272"},"modified":"2023-02-16T14:44:08","modified_gmt":"2023-02-16T06:44:08","slug":"35-promises-lian-shi-cuo-wu-chu-li-he-yun-suan-fu","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=1272","title":{"rendered":"35 &#8211; Promises:\u94fe\u5f0f\u3001\u9519\u8bef\u5904\u7406\u548c\u8fd0\u7b97\u7b26"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/06\/16550338268460.jpg\" alt=\"\" \/><\/p>\n<p>\u539f\u6587\uff1a<a href=\"https:\/\/dev.to\/bhagatparwinder\/promises-chaining-error-handling-operators-3ccb\" target=\"_blank\" rel=\"noopener\">https:\/\/dev.to\/bhagatparwinder\/promises-chaining-error-handling-operators-3ccb<\/a><\/p>\n<p>\u4e0a\u7bc7\u6587\u7ae0\u8be6\u7ec6\u7684\u4ecb\u7ecd\u4e86\u4ec0\u4e48\u662f promise \u4ee5\u53ca\u5982\u4f55\u521b\u5efa\u3001 resolve \u548c reject\u3002<\/p>\n<p>\u8fd9\u4e00\u6b21\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba promise \u4e2d\u7684\u94fe\u5f0f\u64cd\u4f5c\u4ee5\u53ca\u9519\u8bef\u5904\u7406\u548c\u53ef\u7528\u7684\u8fd0\u7b97\u7b26\u3002<\/p>\n<h2><a id=\"%E9%93%BE%E5%BC%8F\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u94fe\u5f0f<\/h2>\n<p>\u56de\u8c03\u51fd\u6570\u6700\u663e\u8457\u7684\u7f3a\u70b9\u4e4b\u4e00\u662f\u5f53\u6211\u4eec\u8fde\u63a5\u5b83\u4eec\u65f6\u5f62\u6210\u7684\u5d4c\u5957\u7ed3\u6784\uff0c\u5728 then \u7684\u5e2e\u52a9\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u66f4\u6613\u9605\u8bfb\u3001\u7406\u89e3\u548c\u8c03\u8bd5\u7684\u6241\u5e73\u7ed3\u6784\u3002<\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a <code>waitForMe<\/code> \u7684\u51fd\u6570\u8fd4\u56de promise\uff0c\u8fd9\u4e2a\u51fd\u6570\u7b49\u5f85 2 \u79d2\u540e\u4f1a\u8fd4\u56de\u4f60\u670b\u53cb\u7684\u540d\u5b57\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function(name) {\n    return new Promise((resolve, reject) =&gt; {\n        setTimeout(() =&gt; {\n            return resolve(name);\n        }, 2000);\n    });\n}\n\nwaitForMe(&quot;Parwinder&quot;)\n    .then((data) =&gt; {\n        console.log(data); \/\/ Outputs\/yells &quot;Parwinder&quot; after 2 second\n    });\n<\/code><\/pre>\n<p>\u5047\u8bbe\u4f60\u6709\u5f88\u591a\u61d2\u60f0\u7684\u670b\u53cb\uff0c\u56e0\u4e3a\u4f60\u5f88\u7740\u6025\u60f3\u90fd\u7ed9\u4ed6\u4eec\u6253\u7535\u8bdd\u3002\u6211\u4eec\u53ef\u4ee5\u4e00\u4e2a\u4e2a\u7684\u7ed9\u4ed6\u4eec\u6253\u7535\u8bdd\uff08\u94fe\u5f0f\u64cd\u4f5c\uff09\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">waitForMe(&quot;Parwinder&quot;)\n    .then((data) =&gt; {\n        console.log(data); \/\/ waits 2 seconds and outputs &quot;Parwinder&quot;\n        return waitForMe(&quot;Lauren&quot;);\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ waits another 2 seconds and outputs &quot;Lauren&quot;\n        return waitForMe(&quot;Robert&quot;);\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ waits another 2 seconds and outputs &quot;Robert&quot;\n        return waitForMe(&quot;Eliu&quot;);\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ waits another 2 seconds and outputs &quot;Eliu&quot;\n    })\n<\/code><\/pre>\n<p>\u4f60\u4f1a\u770b\u5230\u6211\u4eec\u662f\u5982\u4f55\u7528\u94fe\u5f0f\u8c03\u7528\u540d\u5b57\u7684\u4ee5\u53ca\u63a7\u5236\u53f0\u95f4\u9694 2 \u79d2\u6253\u5370\u51fa\u5b83\u4eec\uff0c\u6bcf\u4e00\u4e2a <code>then<\/code> \u64cd\u4f5c\u7b26\u4f1a\u8fd4\u56de\u4e00\u4e2a promise \u7136\u540e\u548c\u5176\u4ed6\u7684 <code>then<\/code> \u94fe\u8d77\u6765\uff0c\u540c\u65f6\u4fdd\u6301\u4ee3\u7801\u7ed3\u6784\u7684\u6241\u5e73\u3002<\/p>\n<h2><a id=\"%E9%94%99%E8%AF%AF%E5%A4%84%E7%90%86\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u9519\u8bef\u5904\u7406<\/h2>\n<p>\u5728 promise \u7684\u94fe\u5f0f\u4e2d\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5904\u7406\u9519\u8bef\uff0c\u8981\u4e48\u5728 <code>then<\/code> \u5757\u4e2d\u4f20\u5165\u9519\u8bef\u5904\u7406\u5668\u6216\u8005\u4f7f\u7528 <code>catch<\/code> \u64cd\u4f5c\u7b26\u3002\u6211\u4eec\u5df2\u7ecf\u5728\u524d\u4e00\u7bc7\u6587\u7ae0\u4e2d\u8ba8\u8bba\u4e86\u7b2c\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const myPromise = new Promise((resolve, reject) =&gt; {\n    setTimeout(() =&gt; {\n        reject(&quot;an error has occurred&quot;);\n    }, 2000)\n});\n\nmyPromise.then((response) =&gt; {\n    console.log(response);\n}, (error) =&gt; {\n    console.log(error); \/\/ an error has occurred\n});\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c<code>then<\/code> \u5305\u542b\u4e24\u4e2a\u56de\u8c03\uff0c\u7b2c\u4e00\u4e2a\u662f\u6210\u529f\u7684\u5904\u7406\u5668\uff0c\u7b2c\u4e8c\u4e2a\u662f\u9519\u8bef\u5904\u7406\u5668\u3002\u4f7f\u7528\u8fd9\u4e24\u4e2a\u5904\u7406\u5668\u662f\u5b8c\u5168\u6ca1\u6709\u95ee\u9898\u7684\u540c\u65f6\u5728\u591a\u6570\u60c5\u51b5\u4e0b\u5de5\u4f5c\u826f\u597d\u3002\u5b83\u4e5f\u6709\u67d0\u4e9b\u7f3a\u70b9\uff1a<\/p>\n<ol>\n<li>\u5982\u679c\u6210\u529f\u5904\u7406\u5668\u4e2d\u4ea7\u751f\u4e86\u9519\u8bef\uff0c\u4f60\u5c06\u65e0\u6cd5\u6355\u83b7\u6216\u5904\u7406\u5b83\uff1b<\/li>\n<li>\u5982\u679c\u4f60\u50cf\u4e0a\u9762\u7684\u94fe\u5f0f\u4f8b\u5b50\u4e00\u6837\u4f7f\u7528\u94fe\u5f0f\u8c03\u7528\uff0c\u4f60\u9700\u8981\u5728\u6bcf\u4e2a <code>then<\/code> \u5757\u4e2d\u6dfb\u52a0\u9519\u8bef\u5904\u7406\u5668\u3002<\/li>\n<\/ol>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e9b\u7f3a\u70b9\uff0c\u6211\u4eec\u4f7f\u7528 <code>catch<\/code> \u64cd\u4f5c\u7b26\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const myPromise = new Promise((resolve, reject) =&gt; {\n    setTimeout(() =&gt; {\n        reject(&quot;an error has occurred&quot;);\n    }, 2000)\n});\n\nmyPromise.then((response) =&gt; {\n    console.log(response);\n}).catch((error) =&gt; {\n    console.log(error); \/\/ an error has occured\n});\n<\/code><\/pre>\n<p>\u5728 promise \u7684\u94fe\u5f0f\u8c03\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528 <code>catch<\/code> \u64cd\u4f5c\u7b26\uff1a<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function (name) {\n    return new Promise((resolve, reject) =&gt; {\n        if (name === &quot;Robert&quot;) {\n            return reject(&quot;Robert is always on time&quot;);\n        } else {\n            setTimeout(() =&gt; {\n                return resolve(name);\n            }, 2000);\n        }\n    });\n}\n\nwaitForMe(&quot;Parwinder&quot;)\n    .then((data) =&gt; {\n        console.log(data); \/\/ wait 2 second and log &quot;Parwinder&quot;\n        return waitForMe(&quot;Lauren&quot;);\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ wait 2 more seconds and log &quot;Lauren&quot;\n        return waitForMe(&quot;Robert&quot;); \/\/ this will result in promise rejection\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ this never gets executed\n        return waitForMe(&quot;Eliu&quot;);\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ this never gets executed\n    })\n    .catch((error) =&gt; {\n        console.log(error); \/\/ Robert is always on time\n    })\n<\/code><\/pre>\n<p>\u8bb0\u4f4f\u5728 promise \u7684\u94fe\u5f0f\u8c03\u7528\u4e2d\u4e00\u65e6\u6709\u4e00\u4e2a\u4ea7\u751f\u9519\u8bef\u540e\u7eed\u7684\u94fe\u5c06\u4f1a\u88ab\u7ec8\u6b62\u3002\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u6700\u540e\u4e24\u4e2a\u6253\u5370\u6ca1\u6709\u6267\u884c\u3002<\/p>\n<p><code>catch<\/code> \u64cd\u4f5c\u7b26\u5e76\u4e0d\u603b\u662f\u5fc5\u987b\u6dfb\u52a0\u5230\u6700\u540e\uff0c\u5b83\u53ef\u4ee5\u6dfb\u52a0\u5230\u94fe\u5f0f\u7684\u4e2d\u95f4\u7136\u540e\u53ef\u4ee5\u6355\u83b7\u5230\u5b83\u90a3\u4e2a\u4f4d\u7f6e\u4e4b\u524d\u7684\u9519\u8bef\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function (name) {\n    return new Promise((resolve, reject) =&gt; {\n        if (name === &quot;Robert&quot;) {\n            return reject(&quot;Robert is always on time&quot;);\n        } else {\n            setTimeout(() =&gt; {\n                return resolve(name);\n            }, 2000);\n        }\n    });\n}\n\nwaitForMe(&quot;Parwinder&quot;)\n    .then((data) =&gt; {\n        console.log(data); \/\/ wait 2 second and log &quot;Parwinder&quot;\n        return waitForMe(&quot;Lauren&quot;);\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ wait 2 more seconds and log &quot;Lauren&quot;\n        return waitForMe(&quot;Robert&quot;); \/\/ this will result in promise rejection\n    })\n    .catch((error) =&gt; { \/\/ catches the promise rejection\n        console.log(error); \/\/ Robert is always on time\n        return waitForMe(&quot;Eliu&quot;); \/\/ continues the chain\n    })\n    .then((data) =&gt; {\n        console.log(data); \/\/ Eliu\n    })\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f\uff1a<\/strong> \u4e3a\u4ec0\u4e48\u4e0d\u4e00\u76f4\u4f7f\u7528 <code>catch<\/code> \u800c\u5ffd\u7565 <code>then<\/code> \u4e2d\u7684\u9519\u8bef\u5904\u7406\u5668\u5462\uff1f<\/p>\n<p>\u6211\u4e0a\u9762\u63d0\u5230\u8fc7 then \u7684\u52a3\u52bf\uff1a<\/p>\n<blockquote>\n<p>\u9700\u8981\u4e3a\u6bcf\u4e00\u4e2a then \u6dfb\u52a0\u4e00\u4e2a\u9519\u8bef\u5904\u7406\u5668\u3002<\/p>\n<\/blockquote>\n<p>\u6709\u65f6\u5019\u4f60\u53ef\u80fd\u9700\u8981\u5728\u94fe\u5f0f <code>then<\/code> \u7684\u9519\u8bef\u5904\u7406\u5668\u4e2d\u6709\u4e0d\u540c\u7684\u9519\u8bef\u5904\u7406\u65b9\u5f0f\uff0c\u57fa\u4e8e\u8fd9\u4e00\u70b9\uff0cthen \u4e2d\u72ec\u7acb\u7684\u9519\u8bef\u5904\u7406\u5668\u53ef\u80fd\u4f1a\u66f4\u6709\u4f18\u52bf\u3002<\/p>\n<h2><a id=\"%E6%93%8D%E4%BD%9C%E7%AC%A6\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u64cd\u4f5c\u7b26<\/h2>\n<p>promise \u4e0a\u6709\u4e24\u4e2a\u91cd\u8981\u7684\u64cd\u4f5c\u7b26\uff0c\u5b83\u4eec\u5206\u522b\u9002\u5e94\u7279\u5b9a\u7684\u573a\u666f\uff1a<code>Promise.all<\/code> \u548c <code>Promise.race<\/code>\u3002<\/p>\n<h3><a id=\"promise-all\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>Promise.all<\/h3>\n<p>\u5f53\u4f60\u5728\u4e00\u4e2a\u5f02\u6b65\u64cd\u4f5c\u540e\u6267\u884c\u53e6\u4e00\u4e2a\uff08\u4e32\u884c\uff09\uff0cpromise \u7684\u94fe\u5f0f\u8c03\u7528\u5f88\u987a\u624b\u3002\u7ecf\u5e38\uff0c\u4f60\u9700\u8981\u591a\u4e2a\u5f02\u6b65\u64cd\u4f5c\u5e76\u884c\u6267\u884c\u800c\u4e0d\u662f\u7b49\u4e00\u4e2a\u6267\u884c\u5b8c\u6210\u540e\u518d\u6267\u884c\u3002\u53e6\u5916\uff0c\u4f60\u7684\u64cd\u4f5c\u4f9d\u8d56\u6240\u6709\u7684\u5f02\u6b65\u64cd\u4f5c\u7684\u5b8c\u6210\u60c5\u51b5\u3002<\/p>\n<p><code>Promise.all<\/code> \u4f7f\u6211\u4eec\u53ef\u4ee5\u540c\u65f6\u6267\u884c\u591a\u4e2a\u5f02\u6b65\u64cd\u4f5c\uff0c\u4f46\u4f9d\u65e7\u9700\u8981\u7b49\u5230\u5b83\u4eec\u90fd\u5b8c\u6210 \u4e86\u624d\u6267\u884c\u56de\u8c03\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function (name) {\n    return new Promise((resolve, reject) =&gt; {\n        setTimeout(() =&gt; {\n            return resolve(name);\n        }, 2000);\n    });\n}\n\nconst firstPromise = waitForMe(&quot;Parwinder&quot;);\nconst secondPromise = waitForMe(&quot;Lauren&quot;);\nconst thirdPromise = waitForMe(&quot;Robert&quot;);\nconst fourthPromise = waitForMe(&quot;Eliu&quot;);\n\nPromise.all([firstPromise, secondPromise, thirdPromise, fourthPromise])\n    .then((data) =&gt; {\n        console.log(data); \/\/ [ 'Parwinder', 'Lauren', 'Robert', 'Eliu' ]\n    });\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u4f8b\u5b50\u540c\u65f6\u6267\u884c\u4e86 promise\uff0c\u7b49\u5230\u5b83\u4eec\u90fd\u8fd4\u56de name \u5c31\u4f1a\u8f93\u51fa\u4e00\u4e2a\u7ed3\u679c\u7684\u6570\u7ec4\u3002\u8fd9\u79cd\u65b9\u5f0f\u6267\u884c\u8017\u8d39 2 \u79d2\uff0c\u94fe\u5f0f\u7684\u5f62\u5f0f\u5219\u8017\u8d39 8 \u79d2\u6765\u8f93\u51fa\u56db\u4e2a\u540d\u5b57\u3002<\/p>\n<p>\u6570\u7ec4\u4e2d\u8f93\u51fa\u987a\u5e8f\u662f\u4e25\u683c\u4e0e\u8f93\u5165 <code>Promise.all<\/code> \u4e2d\u7684\u987a\u5e8f\u662f\u4e00\u81f4\u7684\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong> <code>Promise.all<\/code> \u4e2d\u5373\u4f7f\u6709\u4e00\u4e2a\u9519\u8bef\u4ea7\u751f\uff0c\u6574\u4e2a\u7ed3\u679c\u90fd\u4f1a\u5931\u8d25\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function (name) {\n    return new Promise((resolve, reject) =&gt; {\n        if (name === &quot;Robert&quot;) {\n            return reject(&quot;Robert is always on time&quot;);\n        } else {\n            setTimeout(() =&gt; {\n                return resolve(name);\n            }, 2000);\n        }\n    });\n}\n\nconst firstPromise = waitForMe(&quot;Parwinder&quot;);\nconst secondPromise = waitForMe(&quot;Lauren&quot;);\nconst thirdPromise = waitForMe(&quot;Robert&quot;);\nconst fourthPromise = waitForMe(&quot;Eliu&quot;);\n\nPromise.all([firstPromise, secondPromise, thirdPromise, fourthPromise])\n    .then((data) =&gt; {\n        console.log(data);\n    })\n    .catch((error) =&gt; {\n        console.log(error); \/\/ Robert is always on time\n    })\n<\/code><\/pre>\n<p>\u5b83\u4f1a\u5ffd\u7565\u5176\u4ed6\u6210\u529f\u7684 promise\uff0c\u82e5\u6709\u591a\u4e2a\u9519\u8bef\u5b83\u4f1a\u8fd4\u56de\u8f93\u5165 <code>Promise.all<\/code> \u4e2d\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u53d1\u751f\u9519\u8bef\u7684 promise\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function (name) {\n    return new Promise((resolve, reject) =&gt; {\n        if (name === &quot;Robert&quot;) {\n            return reject(&quot;Robert is always on time&quot;);\n        } else if (name === &quot;Lauren&quot;) {\n            return reject(&quot;Lauren is always on time&quot;);\n        } else {\n            setTimeout(() =&gt; {\n                return resolve(name);\n            }, 2000);\n        }\n    });\n}\n\nconst firstPromise = waitForMe(&quot;Parwinder&quot;);\nconst secondPromise = waitForMe(&quot;Lauren&quot;);\nconst thirdPromise = waitForMe(&quot;Robert&quot;);\nconst fourthPromise = waitForMe(&quot;Eliu&quot;);\n\nPromise.all([firstPromise, secondPromise, thirdPromise, fourthPromise])\n    .then((data) =&gt; {\n        console.log(data);\n    })\n    .catch((error) =&gt; {\n        console.log(error); \/\/ Lauren is always on time\n    })\n<\/code><\/pre>\n<h3><a id=\"promise-race\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>Promise.race<\/h3>\n<p><code>Promise.race<\/code> \u5904\u7406\u4e00\u4e2a\u7279\u6b8a\u7684\u60c5\u5f62\uff0c\u5f53\u4f60\u9700\u8981\u540c\u65f6\u6267\u884c\u591a\u4e2a\u5f02\u6b65\u64cd\u4f5c\uff0c\u4f46\u4e0d\u9700\u8981\u7b49\u5230\u5b83\u4eec\u5168\u90e8\u5b8c\u6210\u3002\u76f8\u53cd\uff0c\u4f60\u60f3\u5f53\u7b2c\u4e00\u4e2a promise \u5b8c\u6210\u540e\u5c3d\u5feb\u6267\u884c\u56de\u8c03\u3002<\/p>\n<pre class=\"line-numbers\"><code class=\"language-plain_text\">const waitForMe = function (name, time) {\n    return new Promise((resolve, reject) =&gt; {\n        setTimeout(() =&gt; {\n            return resolve(name);\n        }, time);\n    });\n}\n\nconst firstPromise = waitForMe(&quot;Parwinder&quot;, 4000);\nconst secondPromise = waitForMe(&quot;Lauren&quot;, 3000);\nconst thirdPromise = waitForMe(&quot;Robert&quot;, 7000);\nconst fourthPromise = waitForMe(&quot;Eliu&quot;, 5000);\n\nPromise.race([firstPromise, secondPromise, thirdPromise, fourthPromise])\n    .then((data) =&gt; {\n        console.log(data); \/\/ Lauren\n    })\n    .catch((error) =&gt; {\n        console.log(error);\n    })\n<\/code><\/pre>\n<p>\u6211\u4e3a <code>setTimeout<\/code> \u6dfb\u52a0\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u8ddf\u7740\u6bcf\u4e00\u4e2a\u540d\u5b57\u6211\u4f20\u5165\u4e86\u4e0d\u540c\u7684\u65f6\u95f4\uff0c&quot;Lauren&quot; \u53ea\u6709 3 \u79d2\u949f\u6240\u4ee5\u5979\u6c38\u8fdc\u4f1a\u8d62\u5f97&quot;\u6bd4\u8d5b&quot;\uff0c\u7136\u540e\u6253\u5370\u51fa\u5979\u7684\u540d\u5b57\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/06\/\u524d\u7aef\u9ed1\u677f\u62a5-7.jpg\" alt=\"\u524d\u7aef\u9ed1\u677f\u62a5\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\uff1ahttps:\/\/dev.to\/bhagatparwinder\/promises-chainin&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[249,2,20,3],"tags":[6,86,146,147],"class_list":["post-1272","post","type-post","status-publish","format-standard","hentry","category-javascript","category-all","category-frontend","category-tech","tag-javascript","tag-promise","tag-promise-all","tag-promise-race"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1272"}],"version-history":[{"count":1,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1272\/revisions"}],"predecessor-version":[{"id":1273,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1272\/revisions\/1273"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}