Persistent token for folders

Somehow my creation of a persistent token for a folder isn’t working. Am I doing something wrong here?

var inputfolder = await fs.getFolder();
    if(inputfolder) {
      var token = await fs.createPersistentToken(inputfolder);
      localStorage.setItem("persistent-token", token);

I’m trying to read it back in with this code …
const inputfolder = await fs.getEntryForPersistentToken(localStorage.getItem(inputfoldertoken));

You are saving it as persistent-token but read it as inputfoldertoken.

Change it to

localStorage.setItem("inputfoldertoken", token);
1 Like

inputfoldertoken is a variable - so that should be fine. But I had a different thought error. I mixed up “createPersistentToken” and “localStorage.setItem(“persistent-token”, token);” - forgetting that “persistent-file” can be any string. It’s all a bit confusing and there’s so little documentation.

Your remark pushed me in the right direction - cheers.