You can use whatever method you like, but it would be better to use a get, if you only fetch data from the server.
You can pass and object with data in a GET request as well,
I have builded a table who manage some data passed from laravel. But i have too many data and of course i use pagination, also i have added a view per page. Every thing works but i dont feel very good with this method. I mean i use post method to pass view per page value with ajax couse my front end is vue js.
//laravel controller
public function getUsers(Request $request)
{
$paginate = $request->perPage;
return new UsersResource(User::paginate($paginate));
}
//Route
Route::any('users/getusers', 'UsersController@getUsers')->name('permissions.getUsers');
and vue method
data() {
return {
displayRecord: 5,
pagination: {
current_page: 1,
},
perPage: {
"10": "10",
"50": "50",
"100": "100",
"500": "500",
},
}
}
getUsers() {
axios.post('/admin/users/getusers?page=' + this.pagination.current_page, {
perPage: this.displayRecord
})
.then(response => {
this.users = response.data.data
this.pagination = response.data.meta
I think there is a better way to make this, just i does not now how
@Sinnbeck I have changed to something like this
axios.get('/getusers', {
params: {
'perPage': this.displayRecord,
'page': this.pagination.current_page
}
})
and using resource collection it work for me.
Get it working as you want by opening the url directly in the browser.
I see in browser but was not able to see on table, and problem was i was working with collection before and should change some things if i switch to json.
But now it work for me. Thank you
Please or to participate in this conversation.