{"id":152411,"date":"2020-09-07T11:17:36","date_gmt":"2020-09-07T03:17:36","guid":{"rendered":"http:\/\/4563.org\/?p=152411"},"modified":"2020-09-07T11:17:36","modified_gmt":"2020-09-07T03:17:36","slug":"nodejs-%e5%a6%82%e4%bd%95%e5%b9%b6%e5%8f%91%e8%af%b7%e6%b1%82%e6%95%b0%e6%8d%ae%e6%8e%a5%e5%8f%a3%ef%bc%8c%e5%b9%b6%e8%bf%94%e5%9b%9e%e6%b1%87%e6%80%bb%e5%90%8e%e7%9a%84%e7%bb%93%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=152411","title":{"rendered":"Nodejs \u5982\u4f55\u5e76\u53d1\u8bf7\u6c42\u6570\u636e\u63a5\u53e3\uff0c\u5e76\u8fd4\u56de\u6c47\u603b\u540e\u7684\u7ed3\u679c\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Nodejs \u5982\u4f55\u5e76\u53d1\u8bf7\u6c42\u6570\u636e\u63a5\u53e3\uff0c\u5e76\u8fd4\u56de\u6c47\u603b\u540e\u7684\u7ed3\u679c\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : s609926202 <\/span>  <span><i><\/i> 18<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u7528 Nodejs \u5199\u4e86\u4e00\u4e2a API \u63a5\u53e3\uff0c\u7528\u4e8e\u8bf7\u6c42\u6307\u5b9a\u6570\u636e\u3002\u8fd9\u4e2a\u63a5\u53e3\u4f1a\u8bf7\u6c42\u4e09\u4e2a\u5176\u4ed6\u7684 API\uff1a<\/p>\n<ol>\n<li>http:\/\/a.com\/api1<\/li>\n<li>http:\/\/b.com\/api2<\/li>\n<li>http:\/\/c.com\/api3<\/li>\n<\/ol>\n<p>\u6211\u7684\u76ee\u7684\u662f\u540c\u65f6\uff08\u5e76\u53d1\uff09\u8bf7\u6c42\u4e0a\u9762\u8fd9\u4e09\u4e2a API\uff0c\u7136\u540e\u6c47\u603b\u8bf7\u6c42\u5230\u7684\u7ed3\u679c\uff0c\u8fd4\u56de\u7ed9\u5ba2\u6237\u7aef\u3002<br \/> \u8bf7\u95ee\u8fd9\u4e2a\u53ef\u4ee5\u5b9e\u73b0\u5417\uff0c\u5bf9 Nodejs \u4e0d\u61c2\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3020274\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hgjian <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             promise.all ?\u597d\u50cf\u53ef\u4ee5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020275\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : flowfire <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             await Promise.all([<br \/> fetch(&#8220;url1&#8221;),<br \/> fetch(&#8220;url2&#8221;),<br \/> fetch(&#8220;url3&#8221;),<br \/>])                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020276\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : c6h6benzene <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u7528\u5305\u88c5\u597d\u7684\u5305\u5982 axios\uff0c\u53ef\u4ee5\u7528 axios.all([request1, request2, request3,&#8230;).then(axios.spread(response1, response2, response3) =&gt; {})\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020277\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coderxy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             promise.all                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020278\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 4196 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f Nodejs \u4e0d\u61c2\u7684\u95ee\u9898\uff0c\u4f60\u5e94\u8be5\u591a\u53bb\u5b66\u4e0b js\uff0c\u7279\u522b\u662f es6+\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020279\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : galikeoy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1.\u56de\u8c03\u5d4c\u5957<br \/>2.\u8bf7\u6c42\u6210\u529f\u8ba1\u6570<br \/>3.promise.all                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020280\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : buffzty <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             async ()=&gt;{<br \/>const task1 = fetch1()<br \/>const task2 = fetch2()<br \/>const task3 = fetch3()<br \/>\/\/ try catch<br \/>const task1Resp = await task1<br \/>const task2Resp = await task2<br \/>const task3Resp = await task3<br \/>\/\/ logic<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020281\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : azcvcza <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             promise.all \u5efa\u8bae\u91cc\u8fb9\u5305\u4e00\u5c42 promise\uff0c\u8fd9\u6837\u5373\u4f7f\u8bf7\u6c42\u9519\u8bef promise.all \u4e5f\u4e0d\u4f1a\u6302\u6389\u5f80\u4e0b\u8d70\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020282\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : evilStart <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @azcvcza promise.allSettled \u53ef\u89e3                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3020283\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : azcvcza <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @evilStart \u4f30\u8ba1\u4e5f\u662f promise.all \u91cc\u5305\u4e00\u5c42 promise \u7684\u8bed\u6cd5\u7cd6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Nodejs \u5982\u4f55\u5e76\u53d1\u8bf7\u6c42\u6570\u636e\u63a5\u53e3&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/152411"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152411"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/152411\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152411"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}