0

I want to send as a part of a Pageable object the direction/order of a query "ASC" or "DESC". So my problem is that even if I set the direction as value of pageable and the API URL Request has this information in it, the Spring backend does not correctly parse the Pageble object and it always shows ASC as direction (I think this may be the default state).

This is my filter method in Angular controller

Controller.prototype.sortByDate = function(asc_desc, isStartDate){
        this.pageable.sort = isStartDate ? "validityStartDate" : "validityEndDate";
        this.pageable.direction = asc_desc;
        this.service.findAll(this.filter, this.pageable).then(function(data){
            this.magazineCollectionSubscriptionList = data.content;
            this.setupPagination( data.totalElements );
            this.changePageSize(size, this.filter);
        }.bind(this));
    }

This is my API call in the Service of this entity

Service.prototype.findAll = function(filter, pageable){
        return this.httpService.post(this.serviceUrl + '/list',filter, { params: pageable });
};

This is the request it creates

enter image description here

And here is what the debug show on IDE

enter image description here

  • 1
    can you show your api whether its expecting pageable as pathvariable or requestparam. or requestbody? – Aakash Garg Jun 18 '20 at 15:13
  • public Page findAll(@RequestBody BasicCompanyMagazineCollectionSubscriptionFilter filter, Pageable pageable){ – César Castro Aroche Jun 18 '20 at 20:35
  • but you are not taking pageable neither in queryparams, nor in requestbody nor in path variable for api. so how will api receive it? shouldn't you also mark it with @RequestParam? – Aakash Garg Jun 19 '20 at 07:08
  • I found the answer here https://stackoverflow.com/questions/44757218/spring-pagination-request-parameters – César Castro Aroche Jun 19 '20 at 07:18
  • Does this answer your question? [Spring pagination - request parameters](https://stackoverflow.com/questions/44757218/spring-pagination-request-parameters) – Aakash Garg Jun 19 '20 at 07:21

0 Answers0