0

I am developing a webpage with shows number of results and has pagination which uses server side pagination with help of pagination tokens. If user clicks on already fetched page then should it make a fetch request? But as per my understanding there is no mapping between pagination tokens and data at server side. Or correct me if there can a mapping at backend and we should be fetching data from server? What is the general or preferred approach?

So if client side storage is the only option(preferred) can anyone tell me which storage method should I prefer for json data or how should I proceed?

I referred this link, https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Client-side_storage And according to it, web storage is for simple data similar to cookies. Can I use it for storing json data?

Or my only option is IndexedDB?

devac
  • 39
  • 7
  • If you need the data to persist across sessions then you can definitely use a client-side storage solution like `localstorage` but if that's not required then you can probably do just fine with either `Redux` or the `React Context API` – ultimoTG Oct 20 '20 at 02:57
  • Also, it's not that you have to use just one of these. You can have all of these working together in your app as you see fit. That's up to you and the requirements of your app. Something to keep in mind - if your data contains any sensitive information, I'd not recommend using `localstorage` or be extra careful to delete or reset when the user session ends. – ultimoTG Oct 20 '20 at 03:00
  • @ultimoTG So it is wise to have pagination token --> json data mapping with React context api? What is the general approach, do we make call to server again for previous pages? – devac Oct 20 '20 at 03:08
  • If your data changes frequently and you need to always have the most recent data shown in your pages, it might be a good idea to fetch the previous pages again. – ultimoTG Oct 20 '20 at 04:03
  • Here's a good article that shows how to handle pagination with React and Redux. https://codeburst.io/react-redux-example-paginated-api-7303d9545016. Hope this helps. – ultimoTG Oct 20 '20 at 04:04

0 Answers0