Level 15
Try to use
Route::apiResource('posts', 'PostController');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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: ""
Please or to participate in this conversation.