Skip to content
Advertisement

POST 404 not found on submit Vue js and Laravel?

I’m new to Vue js. I’m trying to store data. I’m loading <router-view> in welcome.blade.php:

JavaScript

You can see I have 3 links. If I click on the jobseekercreate link, it works, but if I refresh the page I get a 404 error. If I refresh the page on home or about links, I see the Home and About components as normal. Why if I click jobseekercreate link it works, but if I refresh the page I get 404 not found error?

In JobSeekerCreate.vue Component, when I click on ‘create profile’ button I get 2 errors.

1) POST http://vuehighrjobs.test/jobseeker/create 404 (not found)? Maybe this has something to do with issue above?

Here is my code. JobSeekerCreate.vue Component with createProfile method:

JavaScript

routes.js:

JavaScript

web.php:

JavaScript

api.php:

JavaScript

welcome.blade.php file:

JavaScript

and Second error when click ‘create profile’ button is: TypeError: Cannot read property 'experience' of undefined Not sure why, after I click ‘create profile’ button I see the data I entered in the inputs in the Vue console. See screenshot. enter image description here

Advertisement

Answer

its because you just get one parameter in laravel route so its doesnt detect it. you have two solution one is accept all parameters like this:

JavaScript

second is use fallback route here more details https://laravel.com/docs/routing#fallback-routes

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement