I have this code to get API data from https://fakestoreapi.com/products/
<template>
<div>
</div>
</template>
<script>
definePageMeta({
layout: "products"
})
export default {
data () {
return {
data: '',
}
},
async fetch() {
const res = await this.$axios.get('https://fakestoreapi.com/products/')
console.log(res.data)
},
}
</script>
I have installed axios and in nuxt.config.ts
I have:
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
app: {
head: {
title: 'Nuxt',
meta: [
{ name: 'description', content: 'Everything about - Nuxt-3'}
],
link: [
{rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons' }
]
}
},
runtimeConfig: {
currencyKey: process.env.CURRENCY_API_KEY
},
modules: [
"@nuxtjs/tailwindcss",
],
buildModules: [
"@nuxtjs/axios"
],
axios: {
baseURL: '/',
}
})
I have the following in my console
is an experimental feature and its API will likely change.
I am not getting API data in the console.
modules
section. Also, the suspense thing is a warning should not cause any error so far. Set the value to yourdata
state and check your Vue devtools to see if something is wrong. Otherwise, please provide a minimal reproducible example or a public Github repo. β Pritchard