# Ionic storage issue

**URL:** <https://forum.ionicframework.com/t/ionic-storage-issue/105354>\
**Category:** ionic-v3\
**Created:** [September 14, 2017, 8:02am UTC](https://forum.ionicframework.com/t/ionic-storage-issue/105354 "2017-09-14T08:02:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![divyanaireficaz](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@divyanaireficaz](https://forum.ionicframework.com/u/divyanaireficaz)\
**Post date:** [September 14, 2017, 8:02am UTC](https://forum.ionicframework.com/t/ionic-storage-issue/105354/1 "2017-09-14T08:02:52Z")

</div>

I am new to ionic 3.9.2. I want to add the storage to my project, but it showing an error like

“Typescript Error Cannot find name ‘storage’. D:/Ionic/SimBing/src/pages/home/home.ts storage.set(‘uname’, this.model.username); alert(storage.get(‘uname’)); // this.router.navigate([this.returnUrl]);”

Can you please help me to solve the issue… Currently I am checking in browser using ionic serve --l. Is there any issue related to this, I mean whether the storage will work only on device?

Thanks – Divya Eficaz

---

<div class="post-metadata">

**Author:** ![Sidharth\_1999](https://avatars.discourse-cdn.com/v4/letter/s/d78d45/32.png) [@Sidharth\_1999](https://forum.ionicframework.com/u/Sidharth_1999)\
**Post date:** [September 14, 2017, 2:00pm UTC](https://forum.ionicframework.com/t/ionic-storage-issue/105354/2 "2017-09-14T14:00:36Z")

</div>

Storage will work fine on the browser, and on a device (although some people use NativeStorage on devices). You can see your storage set up in the chrome developer tools under :  
Application --\> Storage --\> IndexedDB

Here is how you should implement Storage :

app.module.ts

```
    import { IonicStorageModule } from '@ionic/storage';
    ...

    imports : [IonicStorageModule.forRoot(),
                ...
               ]

```

home.ts

```
  import {Storage} from '@ionic/storage'

  export class HomePage{
       
       constructor(public storage : Storage){
       }

       SetData(somedata){
             this.storage.set('MyData', somedata);
       }
       GetData(){
            this.storage.get('MyData').then((data)=>{
                var myData = data;
            }
       }
  }

```

Implementing storage like this should get rid of your error

---

<div class="post-metadata">

**Author:** ![Sujan12](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sujan12/32/108395_2.png) [@Sujan12](https://forum.ionicframework.com/u/Sujan12)\
**Post date:** [September 14, 2017, 2:03pm UTC](https://forum.ionicframework.com/t/ionic-storage-issue/105354/3 "2017-09-14T14:03:37Z")

</div>

> [@divyanaireficaz](#):
>
> “Typescript Error Cannot find name ‘storage’. D:/Ionic/SimBing/src/pages/home/home.ts storage.set(‘uname’, this.model.username); alert(storage.get(‘uname’)); // this.router.navigate([this.returnUrl]);”

Outside of the constructor you have to use `this.storage`.
