LoginSignup
0
0

More than 3 years have passed since last update.

【Vue.js】axiosを使ってrailsで作成したAPIを呼び出す

Posted at
  async mounted() { 
    const res = await this.$axios.$get(`/api/v1/companies/${this.$route.params.id}`) 
    this.form.admin_email = res.data.email
    this.form.admin_first_name = res.data.first_name
    this.form.admin_last_name = res.data.last_name
    this.form.admin_kind = res.data.role
  },

一部抜粋ではあるが、axiosでapiのデータを表示させたい時の記述。

${this.$route.params.id}これが、nuxt.jsに関係する記述。
これによって、idの値を受け取り、それに応じたapiを良いb出すことができる。

0
0
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
0