Closed Chaoyingz closed 5 years ago
I just tested with one of my project. it work normally. Can you show us your nuxt.config.js
The error you got? You are using nuxt or nuxt-egde and version?
nuxt version: 2.3.4 In index.vue:
async asyncData({ app }) {
const { data } = await app.$axios.get('/topics/hot.json')
return {
topics: data
}
}
i got error like this:
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
in context app, $axios is not found.
Update your dependency @nuxtjs/axios to latest
async asyncData({ $axios }) {
const ip = await $axios.get('/topics/hot.json')
return {
topics: data
}
}
in package.json
"@nuxtjs/axios": "^5.3.6",
in index.vue
async asyncData({ $axios }) {
console.log($axios)
const ip = await $axios.$get('http://icanhazip.com')
return { ip }
}
got error:
undefined
Cannot read property '$get' of undefined
When I deleted asyncData method, The page loads successfully, but Global CSS is not load.
So nuxt.config.js
is not work.
You put again the $ in front of get. Remove it
Cannot read property 'get' of undefined
sorry, I found the isseus, my project nuxt version is not least.
Use create-nuxt-app create project, the default package.json is
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
Change it to
"dev": "nuxt",
hello, I set nuxt project like this https://github.com/bluebeel/now-nuxt/issues/4#issuecomment-451666759, but when I run
yarn run dev
, nuxt.config.js not work. how to solve it.