{"id":2092,"date":"2026-02-05T21:00:47","date_gmt":"2026-02-05T12:00:47","guid":{"rendered":"https:\/\/shirakawa.weblike.jp\/blog-page\/?p=2092"},"modified":"2026-02-06T15:23:27","modified_gmt":"2026-02-06T06:23:27","slug":"%e5%90%8c%e6%9c%9f%e5%87%a6%e7%90%86%e9%80%9a%e5%b8%b8%e3%81%ae%e9%96%a2%e6%95%b0%e3%81%a8%e9%9d%9e%e5%90%8c%e6%9c%9f%e5%87%a6%e7%90%86%e3%83%96%e3%83%ad%e3%83%83%e3%82%af%e7%8a%b6%e6%85%8b","status":"publish","type":"post","link":"https:\/\/shirakawa.weblike.jp\/blog-page\/2026\/02\/05\/%e5%90%8c%e6%9c%9f%e5%87%a6%e7%90%86%e9%80%9a%e5%b8%b8%e3%81%ae%e9%96%a2%e6%95%b0%e3%81%a8%e9%9d%9e%e5%90%8c%e6%9c%9f%e5%87%a6%e7%90%86%e3%83%96%e3%83%ad%e3%83%83%e3%82%af%e7%8a%b6%e6%85%8b\/","title":{"rendered":"Node.js\u306e\u540c\u671f\u51e6\u7406(\u901a\u5e38\u306e\u95a2\u6570)\u3068\u975e\u540c\u671f\u51e6\u7406(\u30d6\u30ed\u30c3\u30af\u3059\u308b\u95a2\u6570)"},"content":{"rendered":"<p>await\u306fJavaScript\uff08\u304a\u3088\u3073TypeScript\uff09\u306e\u975e\u540c\u671f\u51e6\u7406\u3092\u6271\u3046\u305f\u3081\u306e\u69cb\u6587\u3067\u3001\u7279\u306basync\u95a2\u6570\u5185\u3067<br \/>\n\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3068\u306e\u4e8b\u3060\u304c\u3001\u975e\u540c\u671f\u51e6\u7406\u3068\u306f\u5fdc\u7b54\u3092\u5f85\u305f\u306a\u3044\u3068\u8a00\u3046\u3053\u3068\u304b\uff1f (-&gt;DeepSeek)<\/p>\n<p>\u3044\u3044\u8cea\u554f\u3067\u3059\u306d\u3002\u975e\u540c\u671f\u51e6\u7406\u306b\u3064\u3044\u3066\u5c11\u3057\u6574\u7406\u3057\u307e\u3057\u3087\u3046\u3002<br \/>\n\u975e\u540c\u671f\u51e6\u7406\u306f\u300c\u5fdc\u7b54\u3092\u5f85\u305f\u306a\u3044\u300d\u3068\u3044\u3046\u3088\u308a\u3001\u300c\u5fdc\u7b54\u3092\u5f85\u3063\u3066\u3044\u308b\u9593\u306b\u4ed6\u306e\u51e6\u7406\u3092\u9032\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u300d\u3068\u3044\u3046\u306e\u304c\u6b63\u78ba\u306a\u8868\u73fe\u3067\u3059\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u8aac\u660e\u3057\u307e\u3059\uff1a<br \/>\n## \u540c\u671f\u51e6\u7406\uff08Synchronous\uff09<br \/>\n\/\/ \u540c\u671f\u51e6\u7406\u306e\u4f8b<br \/>\nfunction syncExample() {<br \/>\n    console.log(&#8220;1. \u51e6\u7406\u958b\u59cb&#8221;);<br \/>\n    const result = \u9577\u6642\u9593\u304b\u304b\u308b\u51e6\u7406(); \/\/ \u3053\u3053\u3067\u30b9\u30c8\u30c3\u30d7<br \/>\n    console.log(&#8220;2. \u7d50\u679c:&#8221;, result); \/\/ \u4e0a\u306e\u304c\u7d42\u308f\u308b\u307e\u3067\u3053\u3053\u306b\u9032\u3081\u306a\u3044<br \/>\n    console.log(&#8220;3. \u51e6\u7406\u5b8c\u4e86&#8221;);<br \/>\n}<\/p>\n<p>## \u975e\u540c\u671f\u51e6\u7406\uff08Asynchronous\uff09<br \/>\n\/\/ \u975e\u540c\u671f\u51e6\u7406\u306e\u4f8b<br \/>\nasync function asyncExample() {<br \/>\n    console.log(&#8220;1. \u51e6\u7406\u958b\u59cb&#8221;);<br \/>\n    const result = await \u9577\u6642\u9593\u304b\u304b\u308b\u975e\u540c\u671f\u51e6\u7406(); \/\/ \u5f85\u3064\u9593\u306b\u4ed6\u306e\u51e6\u7406\u304c\u53ef\u80fd<br \/>\n    console.log(&#8220;2. \u7d50\u679c:&#8221;, result);<br \/>\n    console.log(&#8220;3. \u51e6\u7406\u5b8c\u4e86&#8221;);<br \/>\n}<\/p>\n<p>## \u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<br \/>\n1. await\u304c\u3042\u308b\u304b\u3089\u3068\u3044\u3063\u3066\u300c\u5b8c\u5168\u306b\u5f85\u305f\u306a\u3044\u300d\u308f\u3051\u3067\u306f\u306a\u3044<br \/>\n   &#8211; `await`\u304c\u3042\u308b\u884c\u3067\u306f\u3001\u305d\u306e\u975e\u540c\u671f\u51e6\u7406\u306e\u7d50\u679c\u304c\u5fc5\u8981\u306a\u5834\u5408\u306b\u5f85\u3064<br \/>\n   &#8211; \u305f\u3060\u3057\u3001JavaScript\u306e\u30e1\u30a4\u30f3\u30b9\u30ec\u30c3\u30c9\u306f\u30d6\u30ed\u30c3\u30af\u3055\u308c\u306a\u3044\uff08\u4ed6\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3067\u304d\u308b\uff09<\/p>\n<p>2. \u5177\u4f53\u7684\u306a\u4f8b\uff1a<br \/>\nasync function example() {<br \/>\n    console.log(&#8220;\u30b9\u30c6\u30c3\u30d71&#8221;);<\/p>\n<p>    \/\/ \u3053\u306efetch\u306f\u5b8c\u4e86\u3059\u308b\u307e\u3067\u5f85\u3064\u304c\u3001\u30d6\u30e9\u30a6\u30b6\u306f\u4ed6\u306e\u64cd\u4f5c\u3092\u53d7\u3051\u4ed8\u3051\u3089\u308c\u308b<br \/>\n    const response = await fetch(&#8216;https:\/\/api.example.com\/data&#8217;);<br \/>\n    const data = await response.json();<br \/>\n    console.log(&#8220;\u30b9\u30c6\u30c3\u30d72&#8221;, data);<\/p>\n<p>    \/\/ \u5225\u306e\u975e\u540c\u671f\u51e6\u7406<br \/>\n    setTimeout(() =&gt; {<br \/>\n        console.log(&#8220;\u30b9\u30c6\u30c3\u30d73\uff08\u30bf\u30a4\u30de\u30fc\uff09&#8221;);<br \/>\n    }, 1000);<br \/>\n    console.log(&#8220;\u30b9\u30c6\u30c3\u30d74&#8221;); \/\/ \u30bf\u30a4\u30de\u30fc\u3092\u5f85\u305f\u305a\u306b\u5b9f\u884c\u3055\u308c\u308b<br \/>\n}<\/p>\n<p>3. \u30a4\u30d9\u30f3\u30c8\u30eb\u30fc\u30d7\u306e\u4ed5\u7d44\u307f\uff1a<br \/>\n   &#8211; JavaScript\u306f\u30b7\u30f3\u30b0\u30eb\u30b9\u30ec\u30c3\u30c9<br \/>\n   &#8211; `await`\u3067\u5f85\u3063\u3066\u3044\u308b\u9593\u3082\u3001\u30a4\u30d9\u30f3\u30c8\u30eb\u30fc\u30d7\u306f\u4ed6\u306e\u30bf\u30b9\u30af\uff08\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3001\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306a\u3069\uff09\u3092\u51e6\u7406\u3067\u304d\u308b<br \/>\n   &#8211; \u975e\u540c\u671f\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u5143\u306e\u95a2\u6570\u306e\u7d9a\u304d\u3092\u5b9f\u884c<\/p>\n<p>`await`\u306f\u300c\u3053\u306e\u7d50\u679c\u304c\u6b32\u3057\u3044\u304b\u3089\u3001\u6e96\u5099\u304c\u3067\u304d\u308b\u307e\u3067\u3053\u306e\u95a2\u6570\u306e\u5b9f\u884c\u3092\u4e00\u6642\u505c\u6b62\u3059\u308b\u3051\u3069\u3001JavaScript\u5168\u4f53\u306f\u52d5\u304d\u7d9a\u3051\u3066\u306d\u300d\u3068\u3044\u3046\u610f\u5473\u3067\u3059\u3002\u3053\u308c\u304c\u975e\u540c\u671f\u51e6\u7406\u306e\u672c\u8cea\u3067\u3059\u3002<\/p>\n<p>\u4e0a\u306e\u975e\u540c\u671f\u51e6\u7406\u306b\u304a\u3044\u3066\u3001\u95a2\u6570\u5185\u306e\u51e6\u7406\u306e\u51e6\u7406\u306e\u9806\u756a\u306f\u5909\u308f\u3089\u306a\u3044\u304b\uff1f<br \/>\n\u9577\u6642\u9593\u304b\u304b\u308b\u975e\u540c\u671f\u51e6\u7406()\u306e\u5fdc\u7b54\u524d\u306bconsole.log(&#8220;2. \u7d50\u679c:&#8221;, result);\u304c\u5b9f\u884c\u3055\u308c\u308b\u304b\uff1f<br \/>\n\u3044\u3044\u3048\u3001`console.log(&#8220;2. \u7d50\u679c:&#8221;, result)`\u306f`await`\u306e\u5f8c\u3067\u5b9f\u884c\u3055\u308c\u308b\u306e\u3067\u3001`\u9577\u6642\u9593\u304b\u304b\u308b\u975e\u540c\u671f\u51e6\u7406()`\u306e\u5fdc\u7b54\u524d\u306b\u5b9f\u884c\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>## \u5177\u4f53\u7684\u306a\u5b9f\u884c\u9806\u5e8f\uff1a<br \/>\nasync function asyncExample() {<br \/>\n    console.log(&#8220;1. \u51e6\u7406\u958b\u59cb&#8221;); \/\/ \u2460 \u6700\u521d\u306b\u5b9f\u884c<\/p>\n<p>    \/\/ \u2461 await\u3067\u3053\u306e\u975e\u540c\u671f\u51e6\u7406\u306e\u5b8c\u4e86\u3092\u5f85\u3064<br \/>\n    const result = await \u9577\u6642\u9593\u304b\u304b\u308b\u975e\u540c\u671f\u51e6\u7406();<\/p>\n<p>    console.log(&#8220;2. \u7d50\u679c:&#8221;, result); \/\/ \u2462 \u975e\u540c\u671f\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u3066\u304b\u3089\u5b9f\u884c<br \/>\n    console.log(&#8220;3. \u51e6\u7406\u5b8c\u4e86&#8221;); \/\/ \u2463<br \/>\n}<\/p>\n<p>## `await`\u306e\u52d5\u4f5c\uff1a<br \/>\n1. \u95a2\u6570\u5185\u306e\u5b9f\u884c\u9806\u5e8f\u306f\u4fdd\u305f\u308c\u308b<br \/>\n2. `await`\u306f\u300c\u3053\u3053\u3067\u4e00\u6642\u505c\u6b62\u300d\u306e\u610f\u5473<br \/>\n3. \u4e00\u6642\u505c\u6b62\u4e2d\u3082JavaScript\u30a8\u30f3\u30b8\u30f3\u306f\u4ed6\u306e\u3053\u3068\u3092\u51e6\u7406\u3067\u304d\u308b<\/p>\n<p>## \u8996\u899a\u7684\u306a\u4f8b\uff1a<br \/>\nasync function demo() {<br \/>\n    console.log(&#8220;A: \u958b\u59cb&#8221;);<\/p>\n<p>    \/\/ 3\u79d2\u304b\u304b\u308b\u975e\u540c\u671f\u51e6\u7406\u3092\u5f85\u3064<br \/>\n    const data = await new Promise(resolve =&gt; {<br \/>\n        setTimeout(() =&gt; {<br \/>\n            console.log(&#8220;B: \u975e\u540c\u671f\u51e6\u7406\u5b8c\u4e86&#8221;);<br \/>\n            resolve(&#8220;\u7d50\u679c\u30c7\u30fc\u30bf&#8221;);<br \/>\n        }, 3000);<br \/>\n    });<\/p>\n<p>    console.log(&#8220;C: \u7d50\u679c\u53d6\u5f97&#8221;, data);<br \/>\n    console.log(&#8220;D: \u7d42\u4e86&#8221;);<br \/>\n}<\/p>\n<p>demo();<br \/>\nconsole.log(&#8220;E: \u95a2\u6570\u5916\u306e\u51e6\u7406&#8221;); \/\/ \u3053\u308c\u306f\u3059\u3050\u5b9f\u884c\u3055\u308c\u308b<\/p>\n<p>### \u5b9f\u884c\u7d50\u679c\uff1a<br \/>\nA: \u958b\u59cb<br \/>\nE: \u95a2\u6570\u5916\u306e\u51e6\u7406  \u2190 \u95a2\u6570\u5916\u306f\u3059\u3050\u5b9f\u884c<br \/>\n\uff083\u79d2\u5f85\u3064\uff09<br \/>\nB: \u975e\u540c\u671f\u51e6\u7406\u5b8c\u4e86<br \/>\nC: \u7d50\u679c\u53d6\u5f97 \u7d50\u679c\u30c7\u30fc\u30bf<br \/>\nD: \u7d42\u4e86<\/p>\n<p>## \u91cd\u8981\u306a\u30dd\u30a4\u30f3\u30c8\uff1a<br \/>\n&#8211; `await`\u306e\u524d\u5f8c\u3067\u306f\u3001\u524d\u2192\u5f8c\u306e\u9806\u5e8f\u306f\u4fdd\u8a3c\u3055\u308c\u308b<br \/>\n&#8211; `await`\u304c\u3042\u308b\u3068\u3001\u305d\u306e\u884c\u3067\u95a2\u6570\u306e\u5b9f\u884c\u306f\u4e00\u6642\u505c\u6b62\u3059\u308b<br \/>\n&#8211; \u305f\u3060\u3057\u3001\u95a2\u6570\u5916\u306e\u30b3\u30fc\u30c9\u306f\u5b9f\u884c\u53ef\u80fd<\/p>\n<p>## \u6bd4\u8f03\uff1a`await`\u306a\u3057\u306e\u5834\u5408<br \/>\nasync function withoutAwait() {<br \/>\n    console.log(&#8220;1. \u958b\u59cb&#8221;);<\/p>\n<p>    \/\/ await\u306a\u3057 \u2192 Promise\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u5373\u5ea7\u306b\u8fd4\u308b<br \/>\n    const promise = \u9577\u6642\u9593\u304b\u304b\u308b\u975e\u540c\u671f\u51e6\u7406();<\/p>\n<p>    console.log(&#8220;2. \u7d50\u679c:&#8221;, promise); \/\/ \u3053\u3053\u306f\u3059\u3050\u5b9f\u884c<br \/>\n    console.log(&#8220;3. \u7d42\u4e86&#8221;);<br \/>\n}<\/p>\n<p>\/\/ \u7d50\u679c\uff1a<br \/>\n\/\/ 1. \u958b\u59cb<br \/>\n\/\/ 2. \u7d50\u679c: Promise {} \u2190 \u5b8c\u4e86\u524d\u306ePromise<br \/>\n\/\/ 3. \u7d42\u4e86<\/p>\n<p>\u7d50\u8ad6\uff1a `await`\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u975e\u540c\u671f\u51e6\u7406\u306e\u5b8c\u4e86\u3092\u5f85\u3063\u3066\u304b\u3089\u6b21\u306b\u9032\u3080\u306e\u3067\u3001\u95a2\u6570\u5185\u306e\u51e6\u7406\u9806\u5e8f\u306f\u540c\u671f\u7684\u306a\u898b\u305f\u76ee\u3068\u540c\u3058\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\/*************************************************************************************\/<br \/>\nPromise\u306e\u89e3\u6c7a\u3068\u306f\u4f55\u304b\uff1f\u307e\u305f\u3001\u4e0a\u306e\u8996\u899a\u7684\u306a\u4f8b\uff1a\u3092await\u3092\u4f7f\u7528\u305b\u305a\u306bPromise\u30c1\u30a7\u30fc\u30f3\u3092\u4f7f\u3046\u5834\u5408\u306e\u30b3\u30fc\u30c9\u306f\u3069\u3046\u306a\u308b\u304b\uff1f<br \/>\n## Promise\u306e\u89e3\u6c7a\u3068\u306f\uff1f<br \/>\nPromise\u306e\u89e3\u6c7a\uff08resolve\uff09 \u3068\u306f\u3001\u975e\u540c\u671f\u51e6\u7406\u304c\u300c\u6210\u529f\u300d\u307e\u305f\u306f\u300c\u5931\u6557\u300d\u306e\u72b6\u614b\u306b\u843d\u3061\u7740\u304f\u3053\u3068\u3092\u6307\u3057\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\uff1a<br \/>\n1. \u89e3\u6c7a\uff08resolve\uff09: \u975e\u540c\u671f\u51e6\u7406\u304c\u6210\u529f\u3057\u3001\u7d50\u679c\u306e\u5024\u304c\u5f97\u3089\u308c\u305f\u72b6\u614b<br \/>\n2. \u62d2\u5426\uff08reject\uff09: \u975e\u540c\u671f\u51e6\u7406\u304c\u5931\u6557\u3057\u3001\u30a8\u30e9\u30fc\u7406\u7531\u304c\u5f97\u3089\u308c\u305f\u72b6\u614b<\/p>\n<p>\/\/ Promise\u306e\u89e3\u6c7a\u4f8b<br \/>\nconst promise = new Promise((resolve, reject) =&gt; {<br \/>\n    setTimeout(() =&gt; {<br \/>\n        \/\/ \u6210\u529f\u6642 \u2192 resolve()\u3067\u89e3\u6c7a<br \/>\n        resolve(&#8220;\u6210\u529f\u30c7\u30fc\u30bf&#8221;);<br \/>\n        \/\/ \u307e\u305f\u306f\u5931\u6557\u6642 \u2192 reject()\u3067\u62d2\u5426<br \/>\n        \/\/ reject(new Error(&#8220;\u30a8\u30e9\u30fc\u767a\u751f&#8221;));<br \/>\n    }, 1000);<br \/>\n});<\/p>\n<p>## await\u3042\u308a\u306e\u30b3\u30fc\u30c9 vs Promise\u30c1\u30a7\u30fc\u30f3\u306e\u30b3\u30fc\u30c9<br \/>\n### await\u3042\u308a\uff08\u5143\u306e\u30b3\u30fc\u30c9\uff09:<br \/>\nasync function demo() {<br \/>\n    console.log(&#8220;A: \u958b\u59cb&#8221;);<br \/>\n    const data = await new Promise(resolve =&gt; {<br \/>\n        setTimeout(() =&gt; {<br \/>\n            console.log(&#8220;B: \u975e\u540c\u671f\u51e6\u7406\u5b8c\u4e86&#8221;);<br \/>\n            resolve(&#8220;\u7d50\u679c\u30c7\u30fc\u30bf&#8221;);<br \/>\n        }, 3000);<br \/>\n    });<br \/>\n    console.log(&#8220;C: \u7d50\u679c\u53d6\u5f97&#8221;, data);<br \/>\n    console.log(&#8220;D: \u7d42\u4e86&#8221;);<br \/>\n}<br \/>\ndemo();<br \/>\nconsole.log(&#8220;E: \u95a2\u6570\u5916\u306e\u51e6\u7406&#8221;);<\/p>\n<p>### await\u306a\u3057\uff08Promise\u30c1\u30a7\u30fc\u30f3\uff09:<br \/>\nfunction demoPromiseChain() {<br \/>\n    console.log(&#8220;A: \u958b\u59cb&#8221;);<br \/>\n    \/\/ Promise\u3092\u8fd4\u3059\uff08await\u306a\u3057\uff09<br \/>\n    return new Promise(resolve =&gt; {<br \/>\n        setTimeout(() =&gt; {<br \/>\n            console.log(&#8220;B: \u975e\u540c\u671f\u51e6\u7406\u5b8c\u4e86&#8221;);<br \/>\n            resolve(&#8220;\u7d50\u679c\u30c7\u30fc\u30bf&#8221;);<br \/>\n        }, 3000);<br \/>\n    })<br \/>\n    .then(data =&gt; {<br \/>\n        console.log(&#8220;C: \u7d50\u679c\u53d6\u5f97&#8221;, data);<br \/>\n        console.log(&#8220;D: \u7d42\u4e86&#8221;);<br \/>\n    });<br \/>\n}<br \/>\ndemoPromiseChain();<br \/>\nconsole.log(&#8220;E: \u95a2\u6570\u5916\u306e\u51e6\u7406&#8221;);<\/p>\n<p>## \u3088\u308a\u8907\u96d1\u306a\u4f8b\u3067\u306e\u6bd4\u8f03<br \/>\n### await\u3092\u4f7f\u3063\u305f\u5834\u5408:<br \/>\nasync function getUserData() {<br \/>\n    try {<br \/>\n        console.log(&#8220;1. \u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u53d6\u5f97\u958b\u59cb&#8221;);<\/p>\n<p>        \/\/ API\u304b\u3089\u30e6\u30fc\u30b6\u30fcID\u53d6\u5f97<br \/>\n        const userId = await fetchUserApi();<br \/>\n        console.log(&#8220;2. \u30e6\u30fc\u30b6\u30fcID\u53d6\u5f97:&#8221;, userId);<\/p>\n<p>        \/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u8a73\u7d30\u60c5\u5831\u53d6\u5f97<br \/>\n        const userDetails = await fetchUserDetails(userId);<br \/>\n        console.log(&#8220;3. \u8a73\u7d30\u60c5\u5831\u53d6\u5f97:&#8221;, userDetails);<\/p>\n<p>        \/\/ \u30e6\u30fc\u30b6\u30fc\u306e\u6ce8\u6587\u5c65\u6b74\u53d6\u5f97<br \/>\n        const orders = await fetchUserOrders(userId);<br \/>\n        console.log(&#8220;4. \u6ce8\u6587\u5c65\u6b74\u53d6\u5f97:&#8221;, orders);<\/p>\n<p>        return { userDetails, orders };<br \/>\n    } catch (error) {<br \/>\n        console.error(&#8220;\u30a8\u30e9\u30fc\u767a\u751f:&#8221;, error);<br \/>\n    }<br \/>\n}<\/p>\n<p>### Promise\u30c1\u30a7\u30fc\u30f3\u3092\u4f7f\u3063\u305f\u5834\u5408:<br \/>\nfunction getUserDataPromise() {<br \/>\n    console.log(&#8220;1. \u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u53d6\u5f97\u958b\u59cb&#8221;);<\/p>\n<p>    return fetchUserApi()<br \/>\n        .then(userId =&gt; {<br \/>\n            console.log(&#8220;2. \u30e6\u30fc\u30b6\u30fcID\u53d6\u5f97:&#8221;, userId);<br \/>\n            return Promise.all([<br \/>\n                fetchUserDetails(userId),<br \/>\n                fetchUserOrders(userId)<br \/>\n            ]);<br \/>\n        })<br \/>\n        .then(([userDetails, orders]) =&gt; {<br \/>\n            console.log(&#8220;3. \u8a73\u7d30\u60c5\u5831\u53d6\u5f97:&#8221;, userDetails);<br \/>\n            console.log(&#8220;4. \u6ce8\u6587\u5c65\u6b74\u53d6\u5f97:&#8221;, orders);<br \/>\n            return { userDetails, orders };<br \/>\n        })<br \/>\n        .catch(error =&gt; {<br \/>\n            console.error(&#8220;\u30a8\u30e9\u30fc\u767a\u751f:&#8221;, error);<br \/>\n        });<br \/>\n}<\/p>\n<p>\n<pre>## \u4e3b\u306a\u9055\u3044\uff1a\r\n| \u7279\u5fb4               | `await` (async\/await)         | Promise\u30c1\u30a7\u30fc\u30f3 (`.then()`)    |\r\n|--------------------|-------------------------------|--------------------------------|\r\n| \u53ef\u8aad\u6027             | \u540c\u671f\u7684\u306a\u898b\u305f\u76ee\u3067\u8aad\u307f\u3084\u3059\u3044    | \u30cd\u30b9\u30c8\u3059\u308b\u3068\u8aad\u307f\u306b\u304f\u3044         |\r\n| \u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0 | `try-catch`\u3067\u307e\u3068\u3081\u3066\u51e6\u7406\u53ef\u80fd | `.catch()`\u304c\u5fc5\u8981               |\r\n| \u30c7\u30d0\u30c3\u30b0           | \u30b9\u30bf\u30c3\u30af\u30c8\u30ec\u30fc\u30b9\u304c\u660e\u78ba        | \u5c11\u3057\u8907\u96d1                       |\r\n| \u5909\u6570\u306e\u30b9\u30b3\u30fc\u30d7     | \u540c\u3058\u30b9\u30b3\u30fc\u30d7\u5185\u3067\u5909\u6570\u4f7f\u7528\u53ef\u80fd  | \u30c1\u30a7\u30fc\u30f3\u9593\u3067\u5909\u6570\u3092\u5171\u6709\u3057\u306b\u304f\u3044 |\r\n| \u76f4\u5217\u51e6\u7406           | \u81ea\u7136\u306b\u66f8\u3051\u308b                  | `.then()`\u306e\u30cd\u30b9\u30c8\u304c\u5fc5\u8981        |<\/pre>\n<\/p>\n<p>## Promise\u30c1\u30a7\u30fc\u30f3\u306e\u30cd\u30b9\u30c8\u554f\u984c\u4f8b:<br \/>\n\/\/ Promise\u30c1\u30a7\u30fc\u30f3\u306e\u30cd\u30b9\u30c8\uff08\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u5730\u7344\u306b\u4f3c\u3066\u3044\u308b\uff09<br \/>\ngetUser()<br \/>\n    .then(user =&gt; {<br \/>\n        return getPosts(user.id)<br \/>\n            .then(posts =&gt; {<br \/>\n                return getComments(posts[0].id)<br \/>\n                    .then(comments =&gt; {<br \/>\n                        console.log(user, posts, comments);<br \/>\n                    });<br \/>\n            });<br \/>\n    });<\/p>\n<p>\/\/ async\/await\u306a\u3089\u3059\u3063\u304d\u308a<br \/>\nasync function getData() {<br \/>\n    const user = await getUser();<br \/>\n    const posts = await getPosts(user.id);<br \/>\n    const comments = await getComments(posts[0].id);<br \/>\n    console.log(user, posts, comments);<br \/>\n}<\/p>\n<p>\u307e\u3068\u3081: Promise\u306e\u89e3\u6c7a\u3068\u306f\u975e\u540c\u671f\u51e6\u7406\u306e\u5b8c\u4e86\u72b6\u614b\uff08\u6210\u529f\/\u5931\u6557\uff09\u3092\u6307\u3057\u3001`async\/await`\u306fPromise\u30c1\u30a7\u30fc\u30f3\u3092\u3088\u308a\u8aad\u307f\u3084\u3059\u304f\u66f8\u304f\u305f\u3081\u306e\u300c\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u30b7\u30e5\u30ac\u30fc\u300d\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>await\u306fJavaScript\uff08\u304a\u3088\u3073TypeScript\uff09\u306e\u975e\u540c\u671f\u51e6\u7406\u3092\u6271\u3046\u305f\u3081\u306e\u69cb\u6587\u3067\u3001\u7279\u306basync\u95a2\u6570\u5185\u3067 \u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u3068\u306e\u4e8b\u3060\u304c\u3001\u975e\u540c\u671f\u51e6\u7406\u3068\u306f\u5fdc\u7b54\u3092\u5f85\u305f\u306a\u3044\u3068\u8a00\u3046\u3053\u3068\u304b\uff1f (-&gt;DeepSeek)  [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-2092","post","type-post","status-publish","format-standard","hentry","category-web-practice"],"_links":{"self":[{"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/posts\/2092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/comments?post=2092"}],"version-history":[{"count":6,"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/posts\/2092\/revisions"}],"predecessor-version":[{"id":2102,"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/posts\/2092\/revisions\/2102"}],"wp:attachment":[{"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/media?parent=2092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/categories?post=2092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shirakawa.weblike.jp\/blog-page\/wp-json\/wp\/v2\/tags?post=2092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}