I know it is undefined. But why the data was not loaded? This is the first problem.
The second problem (the first error) is clear from the initiating code:
mynamespace.easy.load_data(); // loaded later
mynamespace.easy.restore(); // loaded before load_data finished
Edit:
I have removed the call
mynamespace.easy.restore();
but the errors still are the same.
This is the code to load data:
currentNameSpace.easy.load_data = function(e) {
if (!currentNameSpace.easy.initiated )
chrome.storage.local.get({easy: undefined,profiles: undefined, default_profiles: undefined},
(result) => {
currentNameSpace.data.easy = result.easy;
currentNameSpace.data.profiles = result.profiles;
currentNameSpace.data.default_profiles = result.default_profiles;
currentNameSpace.easy.initiated = true;
currentNameSpace.easy.restore();
}
);
}
currentNameSpace.easy is defined.
edit2
I see that only the function
chrome.storage.local.get
is called and it will not step in the callback. So why the error is Cannot read property ‘easy’ of undefined at Object.currentNameSpace.easy.restore
the restore function should not be called if the callback is not called.