{"id":380,"date":"2026-06-26T13:34:59","date_gmt":"2026-06-26T13:34:59","guid":{"rendered":"https:\/\/aabbee.cafe24.com\/?p=380"},"modified":"2026-06-26T14:02:46","modified_gmt":"2026-06-26T14:02:46","slug":"promise-thencatch","status":"publish","type":"post","link":"https:\/\/coalacoding.com\/?p=380","title":{"rendered":"promise-thencatch"},"content":{"rendered":"<blockquote>\n<p><strong>Info<\/strong>: <a href=\"https:\/\/developer.mozilla.org\/ko\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Promise\">Promise : javascript\uc758 \ube44\ub3d9\uae30 \ucc98\ub9ac\ub97c \uc9c0\uc6d0\ud558\ub294 \uac1d\uccb4 \uc911 \ud558\ub098<\/a><\/p>\n<\/blockquote>\n<hr>\n<ol>\n<li>Promise \uac1d\uccb4\ub294 then\uacfc catch  \uba54\uc11c\ub4dc\ub97c \uac00\uc9c0\uace0 \uc788\ub2e4.<br \/>\n1. then (\ucf5c\ubc31) \ub294 \ud1b5\uc2e0\uc131\uacf5\uc2dc \uacb0\uacfc\uac12 \ubc18\ud658<br \/>\n1. catch (\ucf5c\ubc31)  \ub294 \ud1b5\uc2e0\uc5d0\ub7ec\uc2dc \uacb0\uacfc\uac12 \ubc18\ud658<\/li>\n<\/ol>\n<hr>\n<p>  \u2611<strong> promise \uac1d\uccb4\ub97c \ubc18\ud658\ud558\ub294 \ub300\ud45c\uc801\uc778 \ud568\uc218 <strong><strong><code>fetch<\/code><\/strong><\/strong> \ub97c \uc54c\uc544\ubcf4\uc790<\/strong><\/p>\n<blockquote>\n<p><strong>Info<\/strong>: \ud83d\udce2 <strong>Fetch API  \uae30\ubcf8\uc608\uc81c<\/strong><\/p>\n<\/blockquote>\n<hr>\n<p>  \ud83d\udd17<a href=\"https:\/\/developer.mozilla.org\/ko\/docs\/Web\/API\/Fetch_API\">mdn \ubb38\uc11c\ub97c \uc77d\uc5b4\ubcf4\uc790<\/a><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/aabbee.cafe24.com\/wp-content\/uploads\/2026\/06\/01-29.png\" alt=\"\"><\/p>\n<p>  \ud83d\udd17<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/fetch#syntax\">\ubb38\ubc95\uc744 \ubcf4\uc790<\/a><br \/>\n  \ud83d\udd17<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/fetch#return_value\">\ub9ac\ud134\ub418\ub294 \uac12\uc744 \ubcf4\uc790<\/a><\/p>\n<hr>\n<p>  <strong>\u270f\ufe0f\uc2e4\uc2b5 1 <\/strong><\/p>\n<pre><code class=\"language-javascript\">var fetched=fetch(&#39;https:\/\/jsonplaceholder.typicode.com\/photos&#39;);\nconsole.log(`fetched, ${fetched}`)\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/aabbee.cafe24.com\/wp-content\/uploads\/2026\/06\/02-21.png\" alt=\"\ud504\ub85c\ubbf8\uc2a4\uac00 \ubc18\ud658\ub428\n( promise \ub294 \ube44\ub3d9\uae30\ub85c \ub3d9\uc791\ud558\ub294 \uac1d\uccb4\uc774\uba70 then \uacfc catch \ub97c \ud3ec\ud568\ud558\uace0 \uc788\ub2e4 )\"><\/p>\n<p>  <strong>(\u261e\uff9f\u30ee\uff9f)\u261e \ub9e4\uc6b0\uc911\uc694<\/strong><strong>  promise \ub294 \ube44\ub3d9\uae30\ub85c \ub3d9\uc791\ud558\ub294 \uac1d\uccb4\uc774\uba70 then \uacfc catch \ub97c \ud3ec\ud568\ud558\uace0 \uc788\ub2e4<\/strong><br \/>\n  <strong>(\u261e\uff9f\u30ee\uff9f)\u261e \ub9e4\uc6b0\uc911\uc694   <\/strong><strong>then \uacfc catch\ub294 \ucf5c\ubc31\ud568\uc218!<\/strong><\/p>\n<p>  <strong>\u270f\ufe0f\uc2e4\uc2b5 2<\/strong><br \/>\n  then\uc740 fatch \ud1b5\uc2e0\uc774 \uc131\uacf5\uc2dc \ubc18\ud658\ub418\uba70, catch\ub294 \uc624\ub958\uc2dc \ubc18\ud658\ub41c\ub2e4<\/p>\n<pre><code class=\"language-javascript\">var fetched=fetch(&#39;https:\/\/jsonplaceholder.typicode.com\/photos&#39;);\nconsole.log(`fetched, ${fetched}`)\n\tfetched.then((result)=&gt;{console.log(&#39;\uc131\uacf5&#39;,result)})\n\tfetched.catch((reason)=&gt;{console.log(&#39;\uc2e4\ud328&#39;,reason)})\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/aabbee.cafe24.com\/wp-content\/uploads\/2026\/06\/03-14.png\" alt=\"\"><\/p>\n<p><Accordion title=\"then,catch \uc124\uba85\uc2a4\uc0f7\"><br \/>\n![http \ud1b5\uc2e0\uc758 \uc751\ub2f5\uacb0\uacfc \ud655\uc778\ub428](https:\/\/aabbee.cafe24.com\/wp-content\/uploads\/2026\/06\/04-12.png)<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/aabbee.cafe24.com\/wp-content\/uploads\/2026\/06\/05-10.png\" alt=\"catch \uac00 \uc2e4\ud589\ub428\"><br \/>\n<\/Accordion><\/p>\n<p>  <strong>\u270f\ufe0f\uc2e4\uc2b5 3<\/strong><br \/>\n  fetched \uc0dd\ub7b5<\/p>\n<pre><code class=\"language-javascript\">https:\/\/38296b07-33cb-460f-80bc-e30368fe0bd9.mock.pstmn.io\/products&quot;\nfetch(&quot;https:\/\/jsonplaceholder.typicode.com\/user&quot;)\n    .then((result) =&gt; {\n      console.log(&quot;\uc131\uacf5&quot;, result);\n    })\n    .catch((reson) =&gt; {\n      console.log(&quot;\uc2e4\ud328&quot;, reson);\n    });\n<\/code><\/pre>\n<p>  \ud83d\udce2 <strong>fetch \ud568\uc218\uc758 \ubb38\ubc95\uacfc \ub9ac\ud134\uac12\uc758 \uc54c\uc544\ubcf4\uc558\ub2e4. \ubc18\ud658\ub41c \ub370\uc774\ud130\ub97c \ub2e4\ub904\ubcf4\uc790<\/strong><\/p>\n<blockquote>\n<p><strong>Info<\/strong>: \ud83d\udc41\ufe0f\u200d\ud83d\udde8\ufe0f <a href=\"https:\/\/jsonplaceholder.typicode.com\/photos\">https:\/\/jsonplaceholder.typicode.com\/photos<\/a><br \/>\n\uc11c\ubc84\uc5d0 \uc800\uc7a5\ub41c \uc815\ubcf4\ub294 \uc77c\ubc18 \ud14d\uc2a4\ud2b8 \ud615\ud0dc\ub85c<br \/>\n\uc6f9\ud398\uc774\uc9c0\uc5d0 \ucd9c\ub825 \uc2dc\ud0a4\ub824\uba74 \uc6f9\uc5d0\uc11c \uac00\uacf5\ud560\uc218 \uc788\ub294<br \/>\n\uc5b8\uc5b4\ub85c \ubcc0\uacbd\ud574\uc57c \ud55c\ub2e4.<\/p>\n<\/blockquote>\n<p><a href=\"https:\/\/developer.mozilla.org\/ko\/docs\/Web\/API\/Fetch_API\/Using_Fetch\">\ud83d\udd17MDN\ubb38\uc11c\uac00\uae30<\/a>\u21d2 \uacf5\uc2dd\ubb38\uc11c\uc758 \uc608\uc81c \ud65c\uc6a9<br \/>\n<strong>\u270f\ufe0f\uc2e4\uc2b5\uc608\uc81c<\/strong><\/p>\n<pre><code class=\"language-javascript\">fetch(&#39;https:\/\/jsonplaceholder.typicode.com\/photos&#39;)\n  .then((response) =&gt; response.json())\n  .then((data) =&gt; console.log(data));\n<\/code><\/pre>\n<p><a href=\"\/2408361e98a04e2186333cdfccae8c3a\">\ud83d\udd17\ucd94\uac00\uc608\uc81c\ud398\uc774\uc9c0<\/a><\/p>\n<blockquote>\n<p> <strong>\uc815\ub9ac<\/strong><\/p>\n<\/blockquote>\n<ul>\n<li>fetch \ud568\uc218\ub294 promise \uac1d\uccb4\ub97c \ubc18\ud658\ud55c\ub2e4.<\/li>\n<li>promise\uac1d\uccb4\ub294 \ube44\ub3d9\uae30\ub85c \ub3d9\uc791\ud558\uba70 then, catch \uba54\uc18c\ub4dc\uac00 \uc788\ub2e4.<\/li>\n<li>then,catch \ub294 \ucf5c\ubc31\ud568\uc218\uc774\uba70 \uccab\ubc88\uc9f8 \ud30c\ub77c\ubbf8\ud130\ub85c \ud1b5\uc2e0\uc758 \uacb0\uacfc\uac12\uc744 \ubc18\ud658\ubc1b\ub294\ub2e4<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">.then((result)=&gt;{})\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Info: Promise : javascript\uc758 \ube44\ub3d9\uae30 \ucc98\ub9ac\ub97c \uc9c0\uc6d0\ud558\ub294 \uac1d\uccb4 \uc911 \ud558\ub098 Promise \uac1d\uccb4\ub294 then\uacfc catch \uba54\uc11c\ub4dc\ub97c \uac00\uc9c0\uace0 \uc788\ub2e4. 1. then (\ucf5c\ubc31) \ub294 \ud1b5\uc2e0\uc131\uacf5\uc2dc \uacb0\uacfc\uac12 \ubc18\ud658 1. catch (\ucf5c\ubc31) \ub294 \ud1b5\uc2e0\uc5d0\ub7ec\uc2dc \uacb0\uacfc\uac12 \ubc18\ud658 \u2611 promise \uac1d\uccb4\ub97c \ubc18\ud658\ud558\ub294 \ub300\ud45c\uc801\uc778 \ud568\uc218 fetch \ub97c \uc54c\uc544\ubcf4\uc790 Info: \ud83d\udce2 Fetch API \uae30\ubcf8\uc608\uc81c \ud83d\udd17mdn \ubb38\uc11c\ub97c \uc77d\uc5b4\ubcf4\uc790 \ud83d\udd17\ubb38\ubc95\uc744 \ubcf4\uc790 \ud83d\udd17\ub9ac\ud134\ub418\ub294 \uac12\uc744 \ubcf4\uc790 \u270f\ufe0f\uc2e4\uc2b5 1 &#8230; <a title=\"promise-thencatch\" class=\"read-more\" href=\"https:\/\/coalacoding.com\/?p=380\" aria-label=\"promise-thencatch\uc5d0 \ub300\ud574 \ub354 \uc790\uc138\ud788 \uc54c\uc544\ubcf4\uc138\uc694\">\ub354 \uc77d\uae30<\/a><\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-380","post","type-post","status-publish","format-standard","hentry","category-javascript-basics"],"_links":{"self":[{"href":"https:\/\/coalacoding.com\/index.php?rest_route=\/wp\/v2\/posts\/380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coalacoding.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coalacoding.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/coalacoding.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=380"}],"version-history":[{"count":2,"href":"https:\/\/coalacoding.com\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions"}],"predecessor-version":[{"id":2226,"href":"https:\/\/coalacoding.com\/index.php?rest_route=\/wp\/v2\/posts\/380\/revisions\/2226"}],"wp:attachment":[{"href":"https:\/\/coalacoding.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coalacoding.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coalacoding.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}