[Vuejs]-Use axios with Vue and Laravel for post request

0👍

There’s no need to add params in URL since it’s POST request. You should use API routes (api.php) in Laravel and could structure it like this

Route::POST('/vote', 'QuestionController@vote');

Since you place it in api.php as API route, it would be prefixed with /api.
So you axios call should look like this:

addVote(id) {
            axios.post(`/api/vote`, {id: id});
}

Now in your vote method of QuestionController would look like this:

public function vote(Request $request)
{
    dd($request);
}

You will see dump of request data and decide what to do with it.

Leave a comment