# LocalStorage Not defined

**URL:** https://forums.fusetools.com/t/localstorage-not-defined/6679
**Category:** Bug Reports
**Created:** [October 3, 2017, 8:00pm UTC](https://forums.fusetools.com/t/localstorage-not-defined/6679 "2017-10-03T20:00:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Chris\_Timberlake](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@Chris\_Timberlake](https://forums.fusetools.com/u/Chris_Timberlake)
#### Post date: [October 3, 2017, 8:00pm UTC](https://forums.fusetools.com/t/localstorage-not-defined/6679/1 "2017-10-03T20:00:47Z")

</div>

Fuse version 1.2.1 (build 13974)  
OSX

I’m having an issue where localStorage is not defined. Per the release notes a shim should be enabled - but it appears to not exist. This is causing ParseJS to fail. According to the docs and examples, i believe i’m doing everything correctly. This happens in preview and in the iOS Simulator.

```auto
[Viewport]: Error: ReferenceError: localStorage is not defined: Name: ReferenceError: localStorage is not defined
Error message: Uncaught ReferenceError: localStorage is not defined
File name: js/parse.min.js

```

implParse.js

```auto
var Parse = require('./parse.min.js').Parse;

Parse.initialize(
  "[...]",
  "[...]"
);
Parse.serverURL = '[...]';

module.exports = { ParseImpl: Parse }

```

Usage

```auto
var Parse = require("./implParse.js").ParseImpl;
var GameScore = Parse.Object.extend("Venues");
var gameScore = new GameScore();

gameScore.set("Name", "[...]");
gameScore.set("City", "Las Vegas");
gameScore.set("State", "NV");

gameScore.save(null, {
  success: function(gameScore) {
    console.log('New object created with objectId: ' + gameScore.id);
  },
  error: function(gameScore, error) {
    console.log('Failed to create new object, with error code: ' + error.message);
  }
});

```

---

<div class="post-metadata">

### Author: ![Chris\_Timberlake](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@Chris\_Timberlake](https://forums.fusetools.com/u/Chris_Timberlake)
#### Post date: [October 3, 2017, 8:02pm UTC](https://forums.fusetools.com/t/localstorage-not-defined/6679/2 "2017-10-03T20:02:58Z")

</div>

Adding to this - when a shim is applied manually. XMLHTTPRequest also fails to work.

```auto
[Viewport]: Error: Error: Cannot make a request: No definition of XMLHttpRequest was found.: Name: Error: Cannot make a request: No definition of XMLHttpRequest was found.
Error message: Uncaught Error: Cannot make a request: No definition of XMLHttpRequest was found.
File name: js/parse.min.js
Line number: 8403

```

---

<div class="post-metadata">

### Author: ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)
#### Post date: [October 4, 2017, 12:53pm UTC](https://forums.fusetools.com/t/localstorage-not-defined/6679/3 "2017-10-04T12:53:12Z")

</div>

Hi Chris,

I have no idea what `parse.min.js` does with `localStorage`, but this little snippet works just fine in Fuse:

```auto
<App>
    <JavaScript>
    var myStorage = window.localStorage;
    myStorage.setItem("myCat", "Tom");
    console.log(myStorage.getItem("myCat"));
    myStorage.removeItem("myCat");
    </JavaScript>
</App>

```

I’m guessing the problem with `XMLHttpRequest` is going to turn out to be something similar.

---

<div class="post-metadata">

### Author: ![Chris\_Timberlake](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@Chris\_Timberlake](https://forums.fusetools.com/u/Chris_Timberlake)
#### Post date: [October 4, 2017, 6:02pm UTC](https://forums.fusetools.com/t/localstorage-not-defined/6679/4 "2017-10-04T18:02:44Z")

</div>

FuseJS just uses localStorage for caching requests to/from the db. I removed ParseJS and inserted the snipped you posted into my mainview, and the problem remains the same. Adding to that i’ve done `uno clean` and `uno doctor` on the project and neither had a change. It seems the polyfills are nonexistent?

```auto
[Viewport]: Error: ReferenceError: window is not defined: Name: ReferenceError: window is not defined
Error message: Uncaught ReferenceError: window is not defined
File name: MainView.ux
Line number: 14
Source line: var myStorage = window.localStorage;
JS stack trace: ReferenceError: window is not defined
    at Object._tempMethod (MainView.ux:14:21)
 in Fuse.Reactive.DiagnosticSubject<MainView.ux:14>
[Viewport]: Error: ReferenceError: window is not defined: Name: ReferenceError: window is not defined
Error message: Uncaught ReferenceError: window is not defined
File name: MainView.ux
Line number: 14
Source line: var myStorage = window.localStorage;
JS stack trace: ReferenceError: window is not defined
    at Object._tempMethod (MainView.ux:14:21)
 in Fuse.Reactive.DiagnosticSubject<MainView.ux:14>

```

---

<div class="post-metadata">

### Author: ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)
#### Post date: [October 5, 2017, 9:12am UTC](https://forums.fusetools.com/t/localstorage-not-defined/6679/5 "2017-10-05T09:12:37Z")

</div>

It’s a problem on your machine then, because that snippet works perfectly well on mine. Running `uno clean` is nice, but did you rebuild the project after you cleaned? Have you only tested local preview, or device previews too?
