{"id":13983,"date":"2023-08-04T08:08:04","date_gmt":"2023-08-03T23:08:04","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=13983"},"modified":"2023-08-04T08:21:41","modified_gmt":"2023-08-03T23:21:41","slug":"%ea%b0%9c%eb%b0%9c%ec%9a%a9-json-server","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=13983","title":{"rendered":"\uac1c\ubc1c\uc6a9 JSON Server \uac04\ub2e8\ud558\uac8c \uad6c\ucd95\ud558\uae30"},"content":{"rendered":"<p>\uac1c\ubc1c\uc5d0 \uac04\ub2e8\ud788 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 JSON \uc11c\ubc84\ub97c \uad6c\ucd95\ud558\uae30 \uc704\ud55c \uae00\uc785\ub2c8\ub2e4.<\/p>\n<p>\ub2e4\uc74c\ucc98\ub7fc json-server\ub97c \uad6c\ub3d9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>npx json-server --port 9999 --watch db.json<\/code><\/p>\n<p>json-server\uac00 \uc124\uce58\ub418\uc5b4 \uc788\uc9c0 \uc54a\ub2e4\uba74 \uc124\uce58\ud560 \uac83\uc778\uc9c0\ub97c \ubb3b\uace0 \uc124\uce58\ub418\uba74 \uc11c\ubc84\uac00 \uc2e4\ud589\ub429\ub2c8\ub2e4. \ud3ec\ud2b8\ub294 9999\uc774\uace0 \uc11c\ube44\uc2a4\ud560 json \ub370\uc774\ud130\ub294 db.json \ud30c\uc77c\uc774 \uc800\uc7a5\ub418\uc5b4 \uc788\ub294\ub370\uc694. \ub2e4\uc74c \uc608\uc2dc\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\">\r\n{\r\n  \"profile\": {\r\n    \"name\": \"typicode\"\r\n  },\r\n\r\n  \"topics\": [\r\n    {\"id\": 1, \"title\": \"html\", \"body\": \"html is ...\"},\r\n    {\"id\": 2, \"title\": \"css\", \"body\": \"css is ...\"}\r\n  ]\r\n}\r\n<\/pre>\n<p>json \ub370\uc774\ud130\uac00 \uc704\uc640 \uac19\ub2e4\uba74 \ub2e4\uc74c\uacfc \uac19\uc740 url\uc744 \ud1b5\ud574 \uc11c\ubc84\uc5d0 \ub370\uc774\ud130\ub97c \uc694\uccad\ud574 \ubc1b\uc544\uc62c \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>http:\/\/localhost:9999\/topics<br \/>\nhttp:\/\/localhost:9999\/topics\/1<br \/>\nhttp:\/\/localhost:9999\/topics\/2<\/code><\/p>\n<p>\uc774 \uc815\ub3c4\ub3c4 \ub098\uc058\uc9c4 \uc54a\uc73c\ub098 \uc11c\ube44\uc2a4\ud560 \ub370\uc774\ud130\ub97c \ubcc0\uacbd\ud560 \uc218\ub3c4 \uc788\uc2b5\ub2c8\ub2e4. \ud074\ub77c\uc774\uc5b8\ud2b8 \ub2e8\uc5d0\uc11c \uc11c\ube44\uc2a4\ud560 \ub370\uc774\ud130\ub97c \ucd94\uac00\ud558\uae30 \uc704\ud55c \uc11c\ube44\uc2a4 \ud638\ucd9c \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">\r\nconst title = event.target.title.value\r\nconst body = event.target.body.value\r\nconst options = {\r\n  method: \"POST\",\r\n  headers: {\r\n    \"Content-Type\": \"application\/json\"\r\n  },\r\n  body: JSON.stringify({ title, body })\r\n}\r\n\r\nfetch(`http:\/\/localhost:9999\/topics`, options)\r\n  .then(res => res.json())\r\n  .then(result => {\r\n    console.log(result)\r\n  })\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uac00 \uc2e4\ud589\ub418\uba74 \uc11c\ubc84 \ub2e8\uc758 db.json\uc5d0 \uc0c8\ub85c\uc6b4 \ub370\uc774\ud130\uac00 \ucd94\uac00\ub429\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uac1c\ubc1c\uc5d0 \uac04\ub2e8\ud788 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 JSON \uc11c\ubc84\ub97c \uad6c\ucd95\ud558\uae30 \uc704\ud55c \uae00\uc785\ub2c8\ub2e4. \ub2e4\uc74c\ucc98\ub7fc json-server\ub97c \uad6c\ub3d9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. npx json-server &#8211;port 9999 &#8211;watch db.json json-server\uac00 \uc124\uce58\ub418\uc5b4 \uc788\uc9c0 \uc54a\ub2e4\uba74 \uc124\uce58\ud560 \uac83\uc778\uc9c0\ub97c \ubb3b\uace0 \uc124\uce58\ub418\uba74 \uc11c\ubc84\uac00 \uc2e4\ud589\ub429\ub2c8\ub2e4. \ud3ec\ud2b8\ub294 9999\uc774\uace0 \uc11c\ube44\uc2a4\ud560 json \ub370\uc774\ud130\ub294 db.json \ud30c\uc77c\uc774 \uc800\uc7a5\ub418\uc5b4 \uc788\ub294\ub370\uc694. \ub2e4\uc74c \uc608\uc2dc\uc640 \uac19\uc2b5\ub2c8\ub2e4. { &#8220;profile&#8221;: { &#8220;name&#8221;: &#8220;typicode&#8221; }, &#8220;topics&#8221;: [ {&#8220;id&#8221;: 1, &#8220;title&#8221;: &#8220;html&#8221;, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=13983\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;\uac1c\ubc1c\uc6a9 JSON Server \uac04\ub2e8\ud558\uac8c \uad6c\ucd95\ud558\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13983","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13983"}],"version-history":[{"count":4,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13983\/revisions"}],"predecessor-version":[{"id":13986,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13983\/revisions\/13986"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13983"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}