{"id":6001,"date":"2024-01-04T00:08:31","date_gmt":"2024-01-03T15:08:31","guid":{"rendered":"https:\/\/okamurax.com\/?p=6001"},"modified":"2024-01-04T00:08:31","modified_gmt":"2024-01-03T15:08:31","slug":"vue-js-axioscdn%e3%81%a7firestore%e3%81%aeapi%e3%82%92%e5%88%a9%e7%94%a8","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=6001","title":{"rendered":"Vue.js\/axios(CDN)\u3067Firestore\u306eAPI\u3092\u5229\u7528"},"content":{"rendered":"<p><span style=\"color: #0000ff;\">\u5de6\u5074\u30e1\u30cb\u30e5\u30fc&gt;\u69cb\u7bc9&gt;Firestore Database&gt;\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4f5c\u6210<\/span><br \/>\n\u4eca\u56de\u306f\u30c6\u30b9\u30c8\u30e2\u30fc\u30c9\u3067\u958b\u59cb\u3059\u308b\uff61<\/p>\n<pre class=\"lang:js decode:true \">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"ja\"&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=\"UTF-8\"&gt;\r\n  &lt;title&gt;test&lt;\/title&gt;\r\n  &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"&gt;&lt;\/script&gt;\r\n  &lt;script src=\"https:\/\/unpkg.com\/axios\/dist\/axios.min.js\"&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\"&gt;\r\n\r\n&lt;select type=\"text\" v-model=\"selected\"&gt;\r\n  &lt;option&gt;a&lt;\/option&gt;\r\n  &lt;option&gt;b&lt;\/option&gt;\r\n&lt;\/select&gt;\r\n&lt;input type=\"text\" v-model=\"textVal\"&gt;\r\n\r\n&lt;button @click=\"do_post\"&gt;\u767b\u9332&lt;\/button&gt;\r\n&lt;button @click=\"do_get\"&gt;\u53d6\u5f97&lt;\/button&gt;\r\n\r\n&lt;table&gt;\r\n&lt;tr v-for=\"x in lists\"&gt;\r\n  &lt;td&gt;{{ x.fields.a.stringValue }}&lt;\/td&gt;\r\n  &lt;td&gt;{{ x.fields.b.stringValue }}&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n\r\n&lt;\/div&gt;\r\n&lt;script&gt;\r\nlet v = new Vue({\r\n  el: \"#app\",\r\n  data: {\r\n    selected:\"\",\r\n    textVal:\"\",\r\n    lists:[]\r\n  },\r\n  methods:{\r\n    do_get(){\r\n      \/\/ \u30c7\u30fc\u30bf\u53d6\u5f97\r\n      axios\r\n      .get(\"https:\/\/firestore.googleapis.com\/v1\/projects\/[project id]\/databases\/(default)\/documents\/[collection]\")\r\n      .then(response=&gt;{\r\n        this.lists = response.data.documents;\r\n        console.log(response.data.documents);\r\n      });\r\n    },\r\n    do_post(){\r\n      \/\/ \u30c7\u30fc\u30bf\u767b\u9332\r\n      axios\r\n      .post(\"https:\/\/firestore.googleapis.com\/v1\/projects\/[project id]\/databases\/(default)\/documents\/[collection]\",{\r\n        fields:{\r\n          a:{ stringValue:this.selected },\r\n          b:{ stringValue:this.textVal }\r\n        }\r\n      })\r\n      .then(response=&gt;{\r\n        console.log(response);\r\n      })\r\n      .catch(error=&gt;{\r\n        console.log(error);\r\n      });\r\n    }\r\n  }\r\n});\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5de6\u5074\u30e1\u30cb\u30e5\u30fc&gt;\u69cb\u7bc9&gt;Firestore Database&gt;\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u4f5c\u6210 \u4eca\u56de\u306f\u30c6\u30b9\u30c8\u30e2\u30fc\u30c9\u3067\u958b\u59cb\u3059\u308b\uff61 &lt;!DOCTYPE html&gt; &lt;html lang=&#8221;ja&#8221;&gt; &#038; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=6001\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Vue.js\/axios(CDN)\u3067Firestore\u306eAPI\u3092\u5229\u7528&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[139],"class_list":["post-6001","post","type-post","status-publish","format-standard","hentry","category-1","tag-vue-js"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/6001","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6001"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/6001\/revisions"}],"predecessor-version":[{"id":6002,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/6001\/revisions\/6002"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}