Change value in popup.html using (building chrome extension)

Hi everyone,

As a hobby, I am writing an extension for chrome.

I want to load the storage ( and set the value that is there on an element in my popup.html

The screen you see now is the popup (popup.html) screen from the extension. My goal is to fetch data from a page, and show it below Laatste :netherlands:. But since we have to work with a worker I have to use the method using a Promise method.


In my popup.html I have the next html code:

<!DOCTYPE html>
    <link rel="stylesheet" href="styling.css">
<div class="extension">
    <div class="main">
    <div class="huidige-status">Huidige status: {{status}}</div>

    <div class="buttons">
        <button id="lastBiddings">Get offer info</button>


    <div class="last-bids">
        <div id="bids">
            <div id="lastbids">dsassa</div>
<script src="popup.js"></script>


With this popup.js

// When the button is clicked, inject setPageBackgroundColor into current page
startBidding.addEventListener("click", async () => {
    let [tab] = await chrome.tabs.query({active: true, currentWindow: true});
        target: {tabId:},
        function: setPageBackgroundColor,

    const result = await getLocalStorageValue("lastBit");

    document.getElementById('lastbitss').innerText = result;

async function getLocalStorageValue(key) {
    return new Promise((resolve, reject) => {
        try {
  , function (value) {
        catch (ex) {

function setPageBackgroundColor(e) {
    lastBit = document.getElementById("lastbit");'lastBit', lastBit);"color", ({color}) => { = color;

The problem is when

    const result = await getLocalStorageValue("lastBit");

    document.getElementById('lastbitss').innerText = result;

is called in the popup.js I never get the value back. And it wil set [object Object] on the lastbitss element from the popup.html. It does not matter when I set default data in the storage.sync example:'lastBit', 1111);

Did I do the saving/loading wrong to chrome’s API?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.