0

I have an endpoint looking like this

@GetMapping("/page") Page<Event> getEventPage( @PageableDefault(page = 0, size = 20) @SortDefault(sort = "createdDateTime", direction = Sort.Direction.DESC) Pageable pageable)

How am I supposed to pass the Pageable object from my React frontend using Axios, I got this so far:

fetchEvents(pageable) {
    return axios.get("http://localhost:8080/api/events/page", pageable, this.setupAxiosInterceptors());
}

Where pageable is the last fetched page. Now it just resorts to the default values.

user3344447
  • 15
  • 1
  • 4

1 Answers1

0

You simply do this by adding query parameters to the url. Like http://localhost:8080/api/events/page?page=1&size=20

The axios way to do this would be something like this:

const querystring = require('querystring');
axios.get('http://localhost:8080/api/events/page', querystring.stringify({ page: 1, size: 20 }));
n9iels
  • 867
  • 7
  • 21