How are you calling placeEmbedded()?
Are you getting the tokenstring with localStorage.getItem("persistent-file")?
Often a try/catch around the code helps to track down the issue.
BTW please format the code in the posts for better readabelity (it’s the </> icon).