You can use session storage API to store data between pages.
On the first page, load the data from the database, then store it in storage.
On the second page, check if your have saved data. If so, use it. If not, load it from the database.
Checkout the session storage in the reference. It acts like a global variable on the site.