Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to store array in chrome storage api

// by passing an object you can define default values e.g.: []
chrome.storage.local.get({userKeyIds: []}, function (result) {
    // the input argument is ALWAYS an object containing the queried keys
    // so we select the key we need
    var userKeyIds = result.userKeyIds;
    userKeyIds.push({keyPairId: keyPairId, HasBeenUploadedYet: false});
    // set the new array value to the same key
    chrome.storage.local.set({userKeyIds: userKeyIds}, function () {
        // you can use strings instead of objects
        // if you don't  want to define default values
        chrome.storage.local.get('userKeyIds', function (result) {
            console.log(result.userKeyIds)
        });
    });
});
Comment

can you store arrays in chrome storage

// by passing an object you can define default values e.g.: []
chrome.storage.local.get({userKeyIds: []}, function (result) {
    // the input argument is ALWAYS an object containing the queried keys
    // so we select the key we need
    var userKeyIds = result.userKeyIds;
    userKeyIds.push({keyPairId: keyPairId, HasBeenUploadedYet: false});
    // set the new array value to the same key
    chrome.storage.local.set({userKeyIds: userKeyIds}, function () {
        // you can use strings instead of objects
        // if you don't  want to define default values
        chrome.storage.local.get('userKeyIds', function (result) {
            console.log(result.userKeyIds)
        });
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: fastselect clear select 
Javascript :: progressbar jquery 3 ajax 
Javascript :: The attribute name of [ *ngFor ] must be in lowercase.(attr-lowercase) in VSCode 
Javascript :: currency comma separator javascript 
Javascript :: javascript formdata include object 
Javascript :: exit ios inspector in react native 
Javascript :: how to send address of mathods call of solidaty in node 
Javascript :: arrow function no need for curly braces bc just one action 
Javascript :: how to use variable key as dictionary key in javascript 
Javascript :: alegato termino excluido 
Javascript :: select text with vim vscode 
Javascript :: 1493449952 
Javascript :: outline none react native web 
Javascript :: javascript remove junk element from array 
Javascript :: vue expected string with value got number with value 
Javascript :: javascript loop all depths recursive object 
Javascript :: compile pdf with javascript 
Javascript :: es6-map-an-array-of-objects-to-return-an-array-of-objects-with-new-keys 
Javascript :: how to make a box in p5js 
Javascript :: take user value and append value in js 
Javascript :: A react component can only return] 
Javascript :: native module reactnativepushnotification tried to override rnpushnotification 
Javascript :: xslt "node to string" 
Javascript :: react native elements datepicker 
Javascript :: convert javascript function to typescript online 
Javascript :: next js global layout 
Javascript :: jest run current file vscode 
Javascript :: react movies 
Javascript :: convert nested json to query string 
Javascript :: usescript +react 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =