Object object error when trying to save to local storage and display

23 views Asked by At

Been trying to work out why I keep getting an output of [Object, object] instead of what the key is being saved as in local storage.

The function is meant to add a new body of text to a site and keep it there in local storage when the page is refreshed.

function saveEntry() {
    console.log("saveEntry called with variables in scope:", {
            key,
            initialText,
            isNewEntry,
            textareaElement,
    });

    var data = text;
        var item = makeItem("text", data);
        localStorage.setItem(key, item);
        console.log("saved item", key, "=", textareaElement.value);
    }

    textareaElement.addEventListener("change", saveEntry); 
}
0

There are 0 answers