codeforkansascity / clear_my_record_backend

Backend API Code for Clear My Record, an application to assist people the process of expunging their criminal convictions.
MIT License
5 stars 3 forks source link

Pagination API return values #80

Open zmon opened 5 years ago

zmon commented 5 years ago

Screen Shot 2019-06-18 at 11 50 29 PM

Screen Shot 2019-06-19 at 12 09 54 AM

The above example is a search for items with 'an' sorted by City in descending order.

The front end would do a GET with a URL of

.../clients?page=1&keyword=an&column=city&direction=1

And return

{  
   "current_page":1,
   "data":[
      {  
         "id":3,
         "name":"Maybell Daniel",
         "address_line_1":"357 Wolff Via Apt. 414",
         "city":"West Lillastad",
         "state":"Hawaii"
      }, 
      {  
         "id":37,
         "name":"Ms. Callie Shanahan",
         "address_line_1":"3010 Cummings Mall",
         "city":"South Robinchester",
         "state":"New Jersey"
      },
      .
      .
      .
   ],
   "first_page_url":"https:\/clients?page=1",
   "from":1,
   "last_page":3,
   "last_page_url":"https:\/...clients?page=3",
   "next_page_url":"https:\/...clients?page=2",
   "path":"https:\/....clients",
   "per_page":10,
   "prev_page_url":null,
   "to":10,
   "total":22
}

URLs are not correct. We could change the first, last, next, prev _page_url to just be page numbers.