localStorage.getValue() is not a function

  1. My goal: use localStorage API to a credential for my internal API that can be re-used when the page reloads.
  2. Issue: My app was working previously. Today I see: “localStorage.getValue is not a function”. I do not see the function mentioned in the localStorage docs online, so I am wondering if it was removed, whether on purpose or on accident? The localStorage object | Retool Docs
  3. Steps I've taken to troubleshoot: checking docs, searching for other issues like mine, searching for API updates.
  4. Additional info: Cloud

Thanks for reaching out, @Jacob_Muchow - and welcome to the community!

This definitely should work, so I'm not sure why you're getting an error. Is this something you're seeing consistently or just intermittently? Can you check your client version?

I changed to localStorage.values.adminBearerToken instead which I see is an alternative syntax and this works for me now.

It’s curious getValue() was working when I built the app on Thursday, then today it was not working.

Version is 3.291.0, same as the screenshot you sent.

It's very curious! I'm glad you have an alternative, but getValue still works for me. :thinking:

Can you confirm that this is still an issue for you, @Jacob_Muchow? I'd be interested in taking a look during Office Hours, if you're able to join. :+1:

I'm here because I'm getting the same error today.

And yes, localStorage.values[STEER_KEY] works.

The problem I am facing is that one retool app is storing something in localStorage and when another app goes to read it, it is a stale value. I thought maybe "get" would "get the latest".

I'm trying to get two different retool apps to talk to either other efficiently. I went down a rathole trying to make BroadcastChannel work. Apparently even though both retool apps are cloud and are not “same origin” or something....

Advice appreciated.

@Darren

That's bizarre, @Roland_Alden - I'm still not sure why one method wouldn't be recognized when the other is working fine. Thanks for confirming that this is still a recurring issue, though.

Regardless, localStorage might not be a great solution for real-time communication via different apps. I'm pretty sure Retool only syncs with the browser on initial page load and when setting values, meaning you would need to refresh the app to see changes made from another app.

I might be able to offer an alternative with a better understanding of your use case.

Yeah. I discovered that although Retool appA and Retool appB share the localStorage namespace and see each other's values, updates are in fact not transmitted between the two apps except with giant latency and/or app refresh as you suggest.

I wired up a different solution via a shared secret and database in the middle. Latency is high but not infinite :slight_smile: .

The side benefit is that it works when Retool appA and appB are on different computers shared by collaborating users which turns out to be nice unanticipated extra functionality.

Merry Christmas! :wrapped_gift:

2 Likes