I'm having trouble make a save & load function, here's what I'd like to do :
function save(key,val){
chrome.storage.sync.set({key:val}, function() {});
}
function load(key){
chrome.storage.sync.get([key], function(result) {return result});
}
Problem is, by doing that, my save function really create this in storage : {key: "{"key":"val"}"}
The save takes function literally takes "key", instead of taking it as a parameter.
Also, if I want load tu return my value, I need to do "result.key" instead of "result", but same problem, it takes it literally, it doesn't looks at key as a parameter.
And last problem is, if I place my return here, it doesn't work, and return nothing.
Could anyone help me fix it and understand what I did wrong please ?
ps : thanks for the asynchronous part, it helped a bit, I'll use a callback for the returned value, but it doesn't answer the other problems.