var getShortenedUrl = function () {
chrome.tabs.getSelected(null, function (tab) {
var request_data = {
'command': 'generate',
'params': {
'url': tab.url,
'code': text_field.value
}
}
chrome.extension.sendRequest(request_data, function (data) {
switch (data.status) {
case 'OK':
setTextField(data.shortened_url)
bindBtnToCoopy()
chrome.storage.local.get(data.shortened_url, function (arr) {
if (!arr[data.shortened_url]) {
chrome.storage.local.set(
{data.shortened_url:
tab.url}) /* <-- this thing throws an error */
}
})
break
/* ... */
}
})
})
}
see https://github.com/noformnocontent/git-io-chrome/blob/master/chrome/popup.js#L96
and if i comment the chrome.storage.local.set part out, everything is “perfect”
as in the question @pimvdb mentioned, to save an object, i must use an Object.
since then i also released the v.0.5 of “Git.io for Chrome”, see http://git.io/crome for more