Forum Discussion
LocalStorage V2 always returning as undefined
- 11 months ago
Hi hugofernandes,
I replicated your setup using a new visual, and it looks fine in terms of how you're trying to access the API, but I had the same issues as you. This is weird, as I have built visuals for people using this API, so I know it works, but I dug further and found what is hopefully the same root cause as will be for you.
Check your pbiviz.json, under apiVersion. If you've set up a brand new visual using the tools and haven't changed this, the tools set this to 5.3.0 by default, e.g.:
{ "visual": { "name": "storageTest", "displayName": "storageTest", "guid": "storageTestD056CAC136254AB789825C03790B59FA", "visualClassName": "Visual", "version": "1.0.0.0", "description": "", "supportUrl": "", "gitHubUrl": "" }, "apiVersion": "5.3.0", // <------ THIS RIGHT HERE "author": { "name": "", "email": "" }, "assets": { "icon": "assets/icon.png" }, "externalJS": null, "style": "style/visual.less", "capabilities": "capabilities.json", "dependencies": null, "stringResources": [], "version": "1.0.0.0" }If you try to access the V2 local storage API with this version, it will return as undefined, because it wasn't introduced until 5.8.0.
If you set your apiVersion to "5.8.0" or higher (I used 5.9.1), stop your server and re-run the start task, the tools will install the relevant version of powerbi-visuals-api for you, e.g.:
When you re-run this will now show in the console as defined, e.g.:
You should then be able to continue to use as normal.
Good luck!
Daniel
Upgrading the version worked, thanks!!!
I didn't pay attention to the release date of the api, and in the documentation wasn't mentioning anything about it either, thanks!!!
It's a huge misstep in the documentation, as far as I'm concerned, as it tripped me up as well to the point where I was convinced it was broken and I was going to recommend you create a support issue 😅
Glad you're up and running though!