Hello,
not sure but try to remove namespaced: true in auth file
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all, i don't understand why return it:
[vuex] unknown action type: login
index.js
import Vue from 'vue'
import Vuex from 'vuex'
import auth from "./auth";
Vue.use(Vuex)
export default new Vuex.Store({ state: { // TODO }, mutations: { // TODO }, actions: { // TODO }, modules: { auth } })
auth.js
import axios from 'axios'
export default ({ namespaced: true, state: { token: null, user: null }, mutations: { // TODO }, actions: { async login(_, credentials) { let response = await axios.post('/login', credentials) // console.log(response.data); } }, })
main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
axios.defaults.baseURL = 'http://laravel_api.local/api/'
Vue.config.productionTip = false
new Vue({ router, store, render: h => h(App) }).$mount('#app')
Login.vue
<form @submit.prevent="submit">
<div>
<label> Email </label>
<input type="text" name="email" id="email" v-model="form.email">
</div>
<div>
<label> Password </label>
<input type="password" name="password" id="password" v-model="form.password">
</div>
<div>
<button type="submit">sign in</button>
</div>
</form>
import { mapActions } from 'vuex'
export default {
name: 'login',
components: {
//
},
data() {
return {
form: {
email: '',
password: ''
}
}
},
methods: {
...mapActions({
login: 'login'
}),
submit () {
this.login(this.form)
}
}
}
Thank you @franckysolo for help, i resolved it...
'login': 'namespace/myFunction'in my case it is
'login': 'auth/login'
and it's work namespaced: true
Please or to participate in this conversation.