UNE 21, 2021 / #JAVASCRIPT Full JavaScript Course for Beginners

JUNE 21, 2021/[#JAVASCRIPT] # Full JavaScript Course for Beginners (https://www.freecodecamp.org/news/tag/javascript/) at 6:11:27

Problem: In a Chrome Extension I have to be abe to setIems in localStorage and getItems from localStorage. However, I am doing this in jsfiddle.net and it is denying access to local storage. I try with codepen but it does the same thing. I don’t know a good code editor to use so I have been using coding playground. Does anyone know how can I get around this without resorting to having start over with a code editor?

It shouldn’t be blocking it.

You will block localStorage in the browser by not allowing third-party cookies (In Chrome it is “Block third-party cookies”). They are also blocked by default I believe when running in an Incognito window.

This code works for me on Codepen

localStorage.setItem('test', JSON.stringify({message: 'test'}))
document.documentElement.textContent = localStorage.getItem('test');

Are you talking when running the code as an extension or just the tutorial code in the browser?

I have to check on Chrome “Block third-party cookies” issue.
I did run it in Incognito window so that may be one issue.

Thank you so much for solving this problem for me.