Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ethar's avatar
Level 5

Vue Js With Laravel 8 Route Error

i use apiResource to submit data but i got an error

in api.php

Route::apiResource('posts', PostController::class);

in vuejs file create.vue

    methods:{
        submitData(){
            axios.post('api/posts',this.fields).then(res=>{
                this.$router.push('/');
            });
        }
    }

but i got this error

{message: "", exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException",…}
exception: "Symfony\Component\HttpKernel\Exception\NotFoundHttpException"
file: "/Library/WebServer/Documents/LaraVue/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php"
line: 43
message: ""
0 likes
6 replies
arsen-s's avatar

Try to use

Route::apiResource('posts', 'PostController');
ethar's avatar
Level 5

same problem, i use laravel 8

kkhicher1's avatar

@ethar

Its Route not found error.

always make sure that

  1. your api request from root of your domain
  2. Route method exist (try php artisan route:list)
  3. Route or Config Should not be cached (php artisan config:cache, php artisan route:cache, php artisan view:cache) on development server or on live server editing.
submitData(){
            axios.post('/api/posts',this.fields).then(res=>{
                this.$router.push('/');
            });
        }
sr57's avatar

How to you call Vue from Laravel? What is your resources/js/app.js file?

Please or to participate in this conversation.