dimanche 20 août 2017

What to do if there is no data in localStorage?

I'm in a dilemma, I have a search engine which I keep the last results, everything perfect until there.

The problem is that I do not know what to do if I do not have items already saved, ie if it is the first time I search.

if(localStorage.getItem("searchResults") === null) {
  // I do not know what to do here ...
}

else {
  // Here the code is supposed to do what it has to do                 
}

Should not I do anything, should I save an empty string, or would I have to change the logic I'm working on?

What are your friends, what are you doing? Thank you

Aucun commentaire:

Enregistrer un commentaire