boldstar
200
5
Vue

Submitting Post Request From Vue Throwing MethodNotAllowedException

Posted 6 months ago by boldstar

So I changed my set up to use vue for my views and I am attempting to make a login post request which is returning an alarm

exception: "Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException",

Here is my workflow

Vue login component

<template>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card card-default">
                    <div class="card-header">
                        Login
                    </div>

                    <div class="card-body">
                    <form @submit.prevent="login">
                        <input type="text" v-model="username" class="form-control mb-3" placeholder="Email">
                        <input type="password" v-model="password" class="form-control mb-3" placeholder="Password">
                        <div>
                            <button type="submit" class="btn btn-primary btn-block">Login</button>
                        </div>
                    </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'login',
        data() {
            return {
                username: '',
                password: ''
            }
        },
        methods: {
            login() {
                this.$store.dispatch('login', {                    
                    username: this.username,
                    password: this.password
                })
            }
        }
    }
</script>

Here is the store action that I am calling

actions: {
    login(context, credentials) {
        axios.post('/login', {
            username: credentials.username,
            password: credentials.password
        })
        .then(response => {
            context.commit('loggedIn', response.data)
        })
        .catch(error => {
            console.log(error.response.data)
        })
    }
  }

which I want to then send to my web.php routes however I think this is where I am running into my issue

Route::domain('multitenant-diy.test')->group(function () { 
    Route::get('/{any}', '[email protected]')->where('any', '.*');
    Route::post('/login', 'Auth\[email protected]');
});

which is supposed to then call the standard login controller that comes with the auth scaffolding...

Can you make a post request from vuex to the web.php file?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.