Guardé una variable en la clave: data Console.log (data.key), me da mis datos.
Pero ahora envío un mensaje a background.js desde mi popup.js y no lee la línea:
sendResponse(data.key); result = undefined, traté de sacarlo de chrome.storage.local.get("key", function(data) { }) y funcionó con una variable de prueba.
Ventana emergente.js:
chrome.runtime.sendMessage({from: 'popup',subject: 'ubisoft'}, function (result) { window.alert(result) });Fondo.js:
chrome.runtime.onMessage.addListener((msg, sender,sendResponse) => { // First, validate the message's structure. if ((msg.from === 'popup') && (msg.subject === 'ubisoft')) { // Enable the page-action for the requesting tab. chrome.storage.local.get("key", function(data) { // Do something with data.key console.log(data.key) sendResponse(data.key); }); } });