LoginSignup
0
1

More than 3 years have passed since last update.

axios

Last updated at Posted at 2020-09-10

axiosを使ってデータのやり取りをする

npm install axios
import axios from "axios"

cloud firestore rest api検索
結果
https://firestore.googleapis.com/v1/projects/YOUR_PROJECT_ID/databases/(default)/documents/cities/LA

YOUR_PROJECT_IDとcities/LAを変える

methods:{
    createComment(){
      axios.post(”https://firestore.googleapis.com/v1/projects/scrapoo/databases/(default)/documents/comment2”,
      {
        fields:{
          name:{
            stringValue:this.name
          },
          comment:{
            stringValue:this.comment
          }
        }
      }
      )
      .then(response=>{
        console.log(response)
      })
    }
  }

getもpostもおなじurl

baseurlなどの共通の設定はmain.jsで読み込む
なぜならmain.jsが最初に読み込まれるから

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1