How do I execute code at the last comment in the code below? For some reason I'm not allowed to. Isn't my comment within the callback function?
The code is the result of several answers here at Stackoverflow and I don't quite understand what's going on.
browser.browserAction.onClicked.addListener(async tab => {
const contentScriptReady = Promise.all([
browser.tabs.executeScript(tab.id, {file: "axios.min.js"}),
browser.tabs.executeScript(tab.id, {file: "content.js"}),
browser.tabs.executeScript(tab.id, { file: "sweetalert2.all.min.js" }),
browser.tabs.insertCSS(tab.id, { file: "styles.css" })
]);
const connectionStatus = {};
async function getConnectionStatusData(logicalAddress) {
let cooperations = await axios.get('http://api.ntjp.se/coop/api/v1/cooperations.json', {
params: {
connectionPointId: connectionPointId,
logicalAddressId: logicalAddressId,
serviceDomainId: serviceDomainId,
serviceConsumerId: serviceConsumerId,
include: "serviceContract"
}
});
/* some more let x = await axios.get... */
connectionStatus.supportedServiceContracts = await Promise.all( cooperations.data.map(cooperation => axios.get('http://api.ntjp.se/coop/api/v1/serviceProducers.json', {
params: {
connectionPointId,
logicalAddressId,
serviceDomainId,
serviceConsumerId,
serviceContractId: cooperation.serviceContract.id,
},
}).then(response => ({ // I want to process the response but I can't put executable code here
serviceContract: cooperation.serviceContract.namespace,
serviceProducerDescription: response.data[0].description,
serviceProducerHSAId: response.data[0].hsaId,
}))
)
);
await contentScriptReady;
browser.tabs.sendMessage(tab.id, connectionStatus);
}
});