Home

Issue: 489

TypeError: Cannot read property 'params' of undefined

[issue link]

Steps to reproduce

vue init nuxt/starter demo
cd demo
yarn install
yarn add axios

create file pages/users/_id.vue

<template>
  <h1>{{ name }}</h1>
</template>

<script>
import axios from 'axios'

export default {
  data ({ params }) {
    return axios.get(`https://api.myjson.com/bins/${params.id}`)
    .then((res) => res.data)
  }
}
</script>

run npm run dev
visit http://127.0.0.1:3000/users/dgbin

This question is available on Nuxt.js community (#c426)