{"id":7946,"date":"2017-07-10T02:11:52","date_gmt":"2017-07-09T17:11:52","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=7946"},"modified":"2017-07-10T02:11:52","modified_gmt":"2017-07-09T17:11:52","slug":"%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88%e3%82%a8%e3%83%b3%e3%83%89%e9%96%8b%e7%99%ba%e3%81%8c%e6%8d%97%e3%82%8b-json-server%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=7946","title":{"rendered":"\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u304c\u6357\u308b JSON Server\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7959\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/07\/json-logo.png\" alt=\"\" width=\"512\" height=\"203\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/07\/json-logo.png 512w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2017\/07\/json-logo-300x119.png 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/p>\n<p>\u3069\u3082\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u65b0\u898f\u30d7\u30ed\u30c0\u30af\u30c8\u306e\u958b\u767a\u306e\u969b\u306b\u3001\u975e\u5e38\u306b\u91cd\u5b9d\u3059\u308b\u300c<strong>JSON Server<\/strong>\u300d\u306b\u3064\u3044\u3066\u306e\u3054\u7d39\u4ecb\u3067\u304d\u308c\u3070\u3068\u3002<\/p>\n<p>\u771f\u65b0\u3057\u3044\u3082\u306e\u3067\u3082\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u3088\u304f\u5229\u7528\u3057\u3066\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u307e\u3068\u3081\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f55\u304b\u53c2\u8003\u306b\u306a\u308c\u3070\u3068\u3002<\/p>\n<p>\u3068\u3042\u308b\u4e8b\u696d\u3067\u3001\u65b0\u898f\u30d7\u30ed\u30c0\u30af\u30c8\u5236\u4f5c\u304c\u7acb\u3061\u4e0a\u304c\u3063\u3066\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u3092\u884c\u3063\u3066\u3044\u304f\u306b\u3082\u300c<strong>\u30b5\u30fc\u30d0\u30fc\u5074\u304c\u51fa\u6765\u3066\u306a\u3044\u3088\u3049\u3002<\/strong>\u300d<\/p>\n<p>\u3068\u3001\u8a00\u3063\u3066\u5236\u4f5c\u3067\u304d\u306a\u3044\u3068\u3053\u308d\u304c\u767a\u751f\u3059\u308b\u5834\u9762\u306f\u591a\u3005\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3082\u305d\u3082\u3001\u65b0\u898f\u30d7\u30ed\u30c0\u30af\u30c8\u3067\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u304c\u51fa\u6765\u4e0a\u304c\u3063\u3066\u3044\u308b\u72b6\u614b\u3068\u3044\u3046\u306e\u306f\u3001\u306a\u304b\u306a\u304b\u306a\u3044\u72b6\u614b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3093\u306a\u3068\u304d\u306b\u975e\u5e38\u306b\u4fbf\u5229\u306a\u306e\u304c\u300c<strong>JSON Server<\/strong>\u300d\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u300c<strong>JSON Server<\/strong>\u300d\u3067\u3001\u4eee\u306bAPI\u3092\u4f5c\u6210\u3057\u3066\u304a\u3051\u3070\u30b5\u30fc\u30d0\u30fc\u958b\u767a\u304c\u7d42\u3048\u3066\u306a\u304f\u3066\u3082\u30ac\u30c4\u30ac\u30c4\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u958b\u767a\u3092\u3059\u3059\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u901a\u5e38\u306eweb\u30b5\u30fc\u30d3\u30b9\u7b49\u306f\u3001\u3053\u3046\u3044\u3063\u305f\u5834\u9762\u304c\u591a\u304f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u30b2\u30fc\u30e0\u958b\u767a\u3068\u306a\u308b\u3068\u6ca2\u5c71\u306eAPI\u9023\u643a\u3092\u884c\u3044\u5b9f\u88c5\u3059\u308b\u3053\u3068\u3082\u3042\u3063\u3066\u3001\u983b\u7e41\u306b\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u65e9\u901f\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>JSON Server \u4f7f\u3044\u65b9<\/h4>\n<h5>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h5>\n<p>npm \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p><strong>npm \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ npm install -g json-server<\/pre>\n<p>git\u30ec\u30dd\u30b8\u30c8\u30ea\u306f\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>github<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/typicode\/json-server\" target=\"_blank\">https:\/\/github.com\/typicode\/json-server<\/a><\/p>\n<p>global\u306bnpm\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3089\u3001\u30ea\u30bd\u30fc\u30b9\u306e\u4f5c\u6210\u3092\u884c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>db.json<\/strong>\u3068\u3044\u3046\u540d\u524d\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u30ea\u30bd\u30fc\u30b9\u3068\u306a\u308b\u3001json\u3092\u4ee5\u4e0b\u306e\u69d8\u306b\u8a18\u5165\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><strong>db.json<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  \"books\": &#x5B;{\r\n    \"id\": 1,\r\n    \"name\": \"\u30de\u30c7\u30a3\u30bd\u30f3\u90e1\u306e\u6a4b\u00a0\",\r\n    \"author\":\"Robert James Waller\",\r\n    \"rating\": 7.2\r\n  },\r\n  {\r\n     \"id\": 2,\r\n     \"name\": \"\u65e5\u672c\u4e00\u697d\u3057\u3044\u6f22\u5b57\u30c9\u30ea\u30eb \u3046\u3093\u3053\u6f22\u5b57\u30c9\u30ea\u30eb \u5c0f\u5b663\u5e74\u751f\",\r\n     \"author\": \"\u6587\u97ff\u793e\",\r\n     \"rating\": 8.8\r\n  }]\r\n}<\/pre>\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u51fa\u6765\u305f\u3089\u3001json-server\u3092\u7acb\u3061\u4e0a\u3052\u308b\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ json-server --watch db.json<\/pre>\n<p>\u3053\u308c\u3067\u3001\u30b5\u30fc\u30d0\u30fc\u304c\u8d77\u52d5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b9f\u306b\u7c21\u5358\u3067\u3059\u306d\uff01<\/p>\n<p>\u3067\u306f\u3001\u65e9\u901fAPI\u306e\u30e2\u30c3\u30af\u3092\u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h5>\u30e2\u30c3\u30af\u30c6\u30b9\u30c8<\/h5>\n<p>\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u884c\u3048\u308b\u3001curl\u3092\u4f7f\u3063\u3066HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u9001\u4fe1\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ curl -X GET \"http:\/\/localhost:3000\/books\"<\/pre>\n<p>\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u5148\u7a0b\u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u300cbooks\u300d\u306b\u306a\u3063\u3066\u3044\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\u30ec\u30b9\u30dd\u30f3\u30b9<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&#x5B;{\r\n  \"id\": 1,\r\n  \"name\": \"\u30de\u30c7\u30a3\u30bd\u30f3\u90e1\u306e\u6a4b\u00a0\",\r\n  \"author\":\"Robert James Waller\",\r\n  \"rating\": 7.2\r\n},\r\n{\r\n  \"id\": 2,\r\n  \"name\": \"\u65e5\u672c\u4e00\u697d\u3057\u3044\u6f22\u5b57\u30c9\u30ea\u30eb \u3046\u3093\u3053\u6f22\u5b57\u30c9\u30ea\u30eb \u5c0f\u5b663\u5e74\u751f\",\r\n  \"author\": \"\u6587\u97ff\u793e\",\r\n  \"rating\": 8.8\r\n}]<\/pre>\n<p>\u5b9f\u306b\u7c21\u5358\u306bAPI\u30b5\u30fc\u30d0\u3092\u7528\u610f\u3059\u308b\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3057\u305f\u306d\u3002<\/p>\n<h5>RESTful API<\/h5>\n<p>\u300c<strong>JSON Server<\/strong>\u300d\u306fRESTful API\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001URI\u306e\u672b\u5c3e\u306b\u300chttp:\/\/localhost:3000\/books\/1\u300d\u306e\u3088\u3046\u306bid\u756a\u53f7\u3092\u4ed8\u4e0e\u3059\u308b\u3068\u3001<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  \"id\": 1,\r\n  \"name\": \"\u30de\u30c7\u30a3\u30bd\u30f3\u90e1\u306e\u6a4b \",\r\n  \"author\": \"Robert James Waller\",\r\n  \"rating\": 7.2\r\n}<\/pre>\n<p>\u3068\u8a00\u3063\u305f\u611f\u3058\u3067\u3001id1\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306b\u3082\u3001post\u30e1\u30bd\u30c3\u30c9\u3067\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>curl\u30b3\u30de\u30f3\u30c9\u3067\u3001post\u30e1\u30bd\u30c3\u30c9\u3067\u30c7\u30fc\u30bf\u3092\u8ffd\u52a0\u3092\u884c\u3063\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ curl -X POST -H \"Content-Type: application\/json\" -d '{ \"id\": 3, \"name\": \"\u30ce\u30eb\u30a6\u30a7\u30a4\u306e\u68ee\", \"author\": \"\u6751\u4e0a\u6625\u6a39\", \"rating\": 9.0 }' \"http:\/\/localhost:3000\/books\"<\/pre>\n<p>\u30ce\u30eb\u30a6\u30a7\u30a4\u306e\u68ee\u3092\u65b0\u305f\u306b\u8ffd\u52a0\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">{\r\n  \"id\": 3,\r\n  \"name\": \"\u30ce\u30eb\u30a6\u30a7\u30a4\u306e\u68ee\",\r\n  \"author\": \"\u6751\u4e0a\u6625\u6a39\",\r\n  \"rating\": 9\r\n}<\/pre>\n<p>\u3082\u3046\u4e00\u5ea6\u300chttp:\/\/localhost:3000\/books\u300d\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u3068\u3001\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">&#x5B;{\r\n  \"id\": 1,\r\n  \"name\": \"\u30de\u30c7\u30a3\u30bd\u30f3\u90e1\u306e\u6a4b \",\r\n  \"author\": \"Robert James Waller\",\r\n  \"rating\": 7.2\r\n},\r\n{\r\n  \"id\": 2,\r\n  \"name\": \"\u65e5\u672c\u4e00\u697d\u3057\u3044\u6f22\u5b57\u30c9\u30ea\u30eb \u3046\u3093\u3053\u6f22\u5b57\u30c9\u30ea\u30eb \u5c0f\u5b663\u5e74\u751f\",\r\n  \"author\": \"\u6587\u97ff\u793e\",\r\n  \"rating\": 8.8\r\n},\r\n{\r\n  \"id\": 3,\r\n  \"name\": \"\u30ce\u30eb\u30a6\u30a7\u30a4\u306e\u68ee\",\r\n  \"author\": \"\u6751\u4e0a\u6625\u6a39\",\r\n  \"rating\": 9\r\n}]<\/pre>\n<p>db.json\u3082\u4e0a\u8a18\u306e\u7d50\u679c\u3068\u66f8\u304d\u63db\u308f\u3063\u3066\u3044\u307e\u3059\u306e\u3067\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\u3002<\/p>\n<h4>npm script \u3068\u7d44\u307f\u5408\u308f\u305b\u308b<\/h4>\n<p>\u5b9f\u969b\u3001\u30d7\u30ed\u30c0\u30af\u30c8\u3067\u5229\u7528\u3059\u308b\u5834\u5408\u3001\u30ea\u30bd\u30fc\u30b9\u3092\u8ffd\u52a0\u51fa\u6765\u308b\u3088\u3046\u306bnpm script\u3084\u3001glup\u30bf\u30b9\u30af\u7b49\u306b\u8ffd\u52a0\u3059\u308b\u306e\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u4e0a\u8a18\u3067\u306f\u3001db.json\u306b\u76f4\u63a5 JSON\u30c7\u30fc\u30bf\u3092\u8a18\u5165\u3057\u3066\u304a\u308a\u307e\u3057\u305f\u304c\u3001js\u3092\u4ecb\u3057\u3066\u751f\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u8a66\u3057\u306b\u300c<strong>api.js<\/strong>\u300d\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><strong>api.js<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const db = {\r\n  \"books\": &#x5B;{\r\n    \"id\":\u00a01,\u00a0\r\n    \"name\":\u00a0\"\u30de\u30c7\u30a3\u30bd\u30f3\u90e1\u306e\u6a4b\",\u00a0\r\n    \"author\": \"Robert James Waller\",\u00a0\r\n    \"rating\": 7.2\r\n  }, \r\n  {\r\n    \"id\":\u00a02,\u00a0\r\n    \"name\":\u00a0\"\u65e5\u672c\u4e00\u697d\u3057\u3044\u6f22\u5b57\u30c9\u30ea\u30eb \u3046\u3093\u3053\u6f22\u5b57\u30c9\u30ea\u30eb \u5c0f\u5b663\u5e74\u751f\",\u00a0\r\n    \"author\":\u00a0\"\u6587\u97ff\u793e\",\u00a0\r\n    \"rating\":\u00a08.8\r\n  }]\u00a0\r\n}\r\n\r\nconsole.log(JSON.stringify(db));<\/pre>\n<p>\u4e0a\u8a18\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u306enode\u30b3\u30de\u30f3\u30c9\u3067\u53e9\u3044\u3066 db.json\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ node api.js &gt; db.json<\/pre>\n<p>\u78ba\u8a8d\u3059\u308b\u3068\u3001db.json\u304c\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>db.json\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306e script\u3068\u3057\u3066\u3001json:build script\u3068\u3001json\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3059\u308bscript\u306ejson:server script\u3092\u4f5c\u6210\u3059\u308b\u3068\u826f\u3055\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<p>\u3053\u308c\u3089\u3092 npm start \u306e\u969b\u306b\u3001json\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u306escript\u3092\u547c\u3079\u3070\u826f\u3055\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<p>package.json\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u4f5c\u6210\u3002<\/p>\n<p><strong>package.json<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&quot;start&quot;: &quot;concurrently \\&quot;npm run webpack:w\\&quot; \\&quot;npm run json:server\\&quot;&quot;,\r\n&quot;json:build&quot;: &quot;node .\/config\/db\/api\/api.js &gt; .\/config\/db\/db.json&quot;,\r\n&quot;json:server&quot;: &quot;json-server --watch .\/config\/db\/db.json&quot;<\/pre>\n<p>concurrently\u3084webpack\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u4efb\u610f\u3067\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001 npm run json:build \u3067\u3001db.json\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3066\u3001 npm start\u3068\u540c\u6642\u306b\u3001json\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u69d8\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h4>faker<\/h4>\n<p>\u3059\u3079\u3066\u3001\u624b\u4f5c\u696d\u3067\u66f8\u3044\u3066\u3044\u308b\u3068\u3055\u3059\u304c\u306b\u52b9\u7387\u3082\u826f\u304f\u306a\u3044\u306e\u3067\u3001faker\u3092\u4f7f\u3048\u3070\u7c21\u5358\u306b\u30e9\u30f3\u30c0\u30e0\u306b\u597d\u304d\u306a\u3060\u3051\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p><strong>npm \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ npm install faker<\/pre>\n<p><strong>github<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/marak\/Faker.js\/\" target=\"_blank\">https:\/\/github.com\/marak\/Faker.js\/<\/a><\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5b8c\u4e86\u3057\u307e\u3057\u305f\u3089\u3001\u65e9\u901f\u5229\u7528\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>api.js<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">const faker = require('faker');\r\n\r\nconst randomName = faker.name.findName(); \/\/ Rowan Nikolaus<\/pre>\n<p><strong>\u7d50\u679c<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{\"randomName\":\"Colby Douglas\"}<\/pre>\n<p>\u00a0<br \/>\nfaker.name.findName(); \u3067\u3001\u540d\u524d\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306b\u3082\u3001\u69d8\u3005\u306a\u30e6\u30fc\u30b6\u30fc\u60c5\u5831\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">const randomEmail = faker.internet.email(); \/\/ Kassandra.Haley@erich.biz \r\nconst randomCard = faker.helpers.createCard(); \/\/ random contact card containing many properties<\/pre>\n<h5>\u30e9\u30f3\u30c0\u30e0\u306buser\u3092\u8907\u6570\u4f5c\u6210<\/h5>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">const faker = require('faker');\r\nconst db = {\r\n  userList: &#x5B;]\r\n};\r\n\r\nfor (var i = 1; i &lt;= 100; i++) {\r\n  db.userList.push({\r\n    id: i,\r\n    firstName: faker.name.firstName(),\r\n    lastName: faker.name.lastName(),\r\n    email: faker.internet.email(),\r\n    rating: Math.floor(Math.random() * 100 + 1)\/10\r\n  });\r\n}\r\n\r\nconsole.log(JSON.stringify(db));<\/pre>\n<p>faker\u3092\u4f7f\u3048\u3070\u3001\u308f\u3056\u308f\u3056\u3001\u30e6\u30fc\u30b6\u30fc\u30c7\u30fc\u30bf\u30921\u3064\uff11\u3064\u7528\u610f\u3059\u308b\u5fc5\u8981\u3082\u306a\u3055\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<h5>\u30ea\u30bd\u30fc\u30b9\u5358\u4f4d\u3067\u30d5\u30a1\u30a4\u30eb\u5206\u5272<\/h5>\n<p>1\u3064\u306ejs\u30d5\u30a1\u30a4\u30eb\u306b\u4f5c\u6210\u3057\u3066\u3044\u304f\u3068\u3001script\u3082\u5927\u304d\u304f\u306a\u3063\u3066\u3044\u304d\u53ef\u8aad\u6027\u3082\u3088\u308d\u3057\u304f\u306a\u3044\u72b6\u614b\u3068\u306a\u3063\u3066\u3044\u304d\u307e\u3059\u306e\u3067\u3001\u30ea\u30bd\u30fc\u30b9\u5358\u4f4d\u306a\u306e\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u5206\u5272\u3057\u3066\u7ba1\u7406\u3057\u3066\u884c\u304f\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p><strong>book_list.js<\/strong><\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">const book_list = &#x5B;\r\n  {\r\n    \"id\": 1,\r\n    \"name\": \"\u30de\u30c7\u30a3\u30bd\u30f3\u90e1\u306e\u6a4b \",\r\n    \"author\": \"Robert James Waller\",\r\n    \"rating\": 7.2\r\n  },\r\n  {\r\n    \"id\": 2,\r\n    \"name\": \"\u65e5\u672c\u4e00\u697d\u3057\u3044\u6f22\u5b57\u30c9\u30ea\u30eb \u3046\u3093\u3053\u6f22\u5b57\u30c9\u30ea\u30eb \u5c0f\u5b663\u5e74\u751f\",\r\n    \"author\": \"\u6587\u97ff\u793e\",\r\n    \"rating\": 8.8\r\n  },\r\n  {\r\n    \"id\": 3,\r\n    \"name\": \"\u30ce\u30eb\u30a6\u30a7\u30a4\u306e\u68ee\",\r\n    \"author\": \"\u6751\u4e0a\u6625\u6a39\",\r\n    \"rating\": 9\r\n  }];\r\n\r\nmodule.exports.book_list = book_list;\r\napi.js\r\nconst BOOK_LIST = require('.\/book_list').book_list;\r\nconst api = {\r\n  bookList: BOOK_LIST,\r\n  ...\r\n};\r\n\r\nconsole.log(JSON.stringify(api));<\/pre>\n<p>\u3068\u8a00\u3063\u305f\u611f\u3058\u306b\u5206\u3051\u3066\u3044\u3051\u3070\u7ba1\u7406\u3082\u3057\u3084\u3059\u304f\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u3068\u8a00\u3063\u305f\u8a33\u3067\u3001\u4eca\u56de\u306f\u300c<strong>JSON Server<\/strong>\u300d\u306b\u95a2\u3057\u3066\u3067\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u3041\u3002\u307e\u305f\u307e\u305f\u3041\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002 \u4eca\u56de\u306f\u3001\u65b0\u898f\u30d7\u30ed\u30c0\u30af\u30c8\u306e\u958b\u767a\u306e\u969b\u306b\u3001\u975e\u5e38\u306b\u91cd\u5b9d\u3059\u308b\u300cJSON Server\u300d\u306b\u3064\u3044\u3066\u306e\u3054\u7d39\u4ecb\u3067\u304d\u308c\u3070\u3068\u3002 \u771f\u65b0\u3057\u3044\u3082\u306e\u3067\u3082\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u3088\u304f\u5229\u7528\u3057\u3066\u305b\u3063\u304b\u304f\u306a\u306e\u3067\u307e\u3068\u3081\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002 \u4f55\u304b\u53c2\u8003\u306b\u306a\u308c\u3070\u3068 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[171,59,167,177,166,37,47,179,50,169,107,180,173,58,69,150,44,45,39,178,138,78,114,118],"class_list":{"0":"post-7946","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-javascript","7":"tag-android","8":"tag-android-sdk","9":"tag-css","10":"tag-css3","11":"tag-iphone","12":"tag-iphone-","13":"tag-javascript-2","14":"tag-jquery","15":"tag-jquery-mobile","16":"tag-mac","17":"tag-mamp","18":"tag-mysql","19":"tag-php","20":"tag-sdk","21":"tag-transform","22":"tag-vagrant","23":"tag-web","25":"tag-39","26":"tag-178","27":"tag-138","28":"tag-78","29":"tag-114","30":"tag-118"},"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7946"}],"version-history":[{"count":14,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7946\/revisions"}],"predecessor-version":[{"id":7961,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/7946\/revisions\/7961"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}