the culprit might be the forgotten. '/' 👇
let response = await this.$axios.$get('/categories')
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, could anyone help me? I can't connect to the backend of the application. I'm not getting any bugs just the store won't fill it with data. I checked the API via postman and there it's all ok the data is coming back with the app. I use Nuxt.js and the code I have the following ...
index.js
export const state = () => ({
categories: []
})
export const getters = {
categories(state) {
return state.categories
}
}
export const mutations = {
SET_CATEGORIES(state, categories) {
state.categories = categories
}
}
export const actions = {
async nuxtServerInit({ commit }) {
let response = await this.$axios.$get('categories')
commit('SET_CATEGORIES', response.data)
}
}
nuxt.config.js
export default {
// Disable server-side rendering (https://go.nuxtjs.dev/ssr-mode)
ssr: false,
// Global page headers (https://go.nuxtjs.dev/config-head)
head: {
title: 'shopclient',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
// Global CSS (https://go.nuxtjs.dev/config-css)
css: [
],
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [
],
// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
// https://go.nuxtjs.dev/tailwindcss
'@nuxtjs/tailwindcss',
],
// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
'@nuxtjs/axios'
],
axios: {
baseURL: 'http://127.0.0.1:8000/api',
},
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
}
}
Please or to participate in this conversation.