'How to get values from chrome.storage in a forEach loop?
I am creating an extension that stores selected text in local and retrieves that value and prints it in an ongoing list. Each time the text is selected and added, it is added to the noteList.
if(note.menuItemId === "addNote") {
let noteText = note.selectionText //noteText = selected note text
chrome.storage.sync.set({'noteList': noteText})
Now this selected text has to be get from the local storage and printed in a list format in a way that everytime the user sets a new value a new listitem is created with that new text.
let textArea = document.getElementById('textArea') //textArea inside a list element
chrome.storage.sync.get('noteList', function(updateNote){
let noteListArray = new Array();
list.innerHTML = '';
textArea.value = String(updateNote.noteList)
noteListArray.push(textArea.value)
noteListArray.forEach(function(item){
let list = document.createElement("list")
let text = document.createTextNode(item)
list.appendChild(text)
document.getElementById("notesList").appendChild(list);
})
Now the problem is, I am not able to create a new list item. How should I proceed in this case.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
