How to check an uninitialised chrome storage?

111 views Asked by At

I'm trying to check if the storage is empty, but it gives an error saying data needs to be set before it can even get from the storage.

chrome.storage.sync.get('pos', function(r){
   if (typeof r.pos === undefined ){

      }
    })

edit: The error I get is: Invocation of form get(string) doesn't match definition get(optional string or array or object keys, function callback) at normalizeArgumentsAndValidate (extensions::schemaUtils:112:11) at StorageArea.self.(anonymous function) [as get] (extensions::StorageArea:35:14) at chrome-extension://lqhqq.....

here is a similar question: Making an Array in chrome.storage and retrieving data

0

There are 0 answers