I'm trying to fetch API data from using this code:
<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 axios installed and in my nuxt.config.ts
file, I added:
// 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: '/',
}
})
When I check my console, I see the following message:
is an experimental feature and its API will likely change.
However, I am not seeing any API data being logged in the console. What could be the issue?