From the course: JavaScript: Client-Side Data Storage

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Retrieve items from IndexedDB

Retrieve items from IndexedDB - JavaScript Tutorial

From the course: JavaScript: Client-Side Data Storage

Start my 1-month free trial

Retrieve items from IndexedDB

- Now it would be nice to be able to get the data from our database and show it on our application. And we'll do with our database with the help of a cursor. A cursor, in short, is the result of a query that allows us to iterate through the results, and therefore, list our contacts, in this case. Let's get to it. So the first thing we'll do, we'll do like last time, we'll create a function like the addData function that we have here, and this one will be to displayData. So let's go ahead and do that function, displayData. The first thing we'll do in this function is make sure that we empty the contents of our list, because if we don't do that, we'll re-display the same things every time we refresh the page, so we want to make sure we do this first. So we'll have a list first and let's make sure we create also the list object at the top here. Let's create a constant named list, and this will be from the document.querySelector again, and we'll select the UL element, in this case, which…

Contents