# getItem() returning NULL value

**URL:** <https://forum.wixstudio.com/t/getitem-returning-null-value/5362>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [March 29, 2021, 7:17am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362 "2021-03-29T07:17:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![theastylesie](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/theastylesie/32/9740_2.png) [@theastylesie](https://forum.wixstudio.com/u/theastylesie)\
**Post date:** [March 29, 2021, 7:17am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/1 "2021-03-29T07:17:30Z")

</div>

I found out about setItem() and getItem() as my solution to save value that can be used in another page, but I am getting NULL in 2nd page, here is the code **in Page 1**

import {local} from ‘wix-storage’ ;  
export function box8\_click(event,$w) {  
local.setItem( “jsundertf” , “T-Shirt” );  
}

**Code in Page 2**

import {local} from ‘wix-storage’ ;

export function button1\_click(event,$w) { \   
let x= local.getItem( “jsundertf” ) ;  
console.log(x)  
}

Returns NULL

I have tried with session and memory, but the result is still the same.

I want to create a value using setItem() in one page and retrieve the same value in another page using getItem(). Please help, I am very new in this programing and web development. I am stuck badly. Thanks in advance

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [March 29, 2021, 11:51am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/2 "2021-03-29T11:51:39Z")

</div>

Normaly your generated CODE should work.

But anyway, try this way…

Main-Page-Code:

```javascript
import {local} from 'wix-storage';
import wixLocation from 'wix-location';

$w.onReady(function () {
  $w('#button1').onClick(()=>{
      local.setItem("key1", "T-Shirt"); 
      wixLocation.to("insertHereTheUrlOfTheSecondSite")//Navigation to second site
  });
});

```

Sub-Page-Code:

```javascript
import {local} from 'wix-storage';

$w.onReady(function () {
    $w('#button1').onClick(()=>{
 let x =local.getItem("key1"); 
        console.log(x) 
    });
});

```

Good luck.

---

<div class="post-metadata">

**Author:** ![theastylesie](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/theastylesie/32/9740_2.png) [@theastylesie](https://forum.wixstudio.com/u/theastylesie)\
**Post date:** [March 30, 2021, 7:57am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/3 "2021-03-30T07:57:00Z")

</div>

You are a genius. Thank you so much. But why is it not redirecting to the page link given? Please help.

---

<div class="post-metadata">

**Author:** ![kylieparr2yfs8906](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kylieparr2yfs8906/32/28650_2.png) [@kylieparr2yfs8906](https://forum.wixstudio.com/u/kylieparr2yfs8906)\
**Post date:** [March 30, 2021, 8:40am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/4 "2021-03-30T08:40:23Z")

</div>

Thanks for information

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [March 30, 2021, 9:41am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/5 "2021-03-30T09:41:33Z")

</div>

@theastylesie  
Did you change → ["insert](http://wixlocation.to/) HereTheUrlOfTheSecondSite " to your own link  
Do you use dynamic pages?

Please take a look onto this API:  
[https://www.wix.com/velo/reference/wix-location](https://www.wix.com/velo/reference/wix-location)  
…especialy this one…  
[https://www.wix.com/velo/reference/wix-location/to](https://www.wix.com/velo/reference/wix-location/to)

---

<div class="post-metadata">

**Author:** ![theastylesie](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/theastylesie/32/9740_2.png) [@theastylesie](https://forum.wixstudio.com/u/theastylesie)\
**Post date:** [March 30, 2021, 10:15am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/6 "2021-03-30T10:15:39Z")

</div>

@russian-dima Wonderful. It is working now. Thanks a trillion.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [March 30, 2021, 10:18am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/7 "2021-03-30T10:18:55Z")

</div>

@theastylesie  
No problem. 😉

---

<div class="post-metadata">

**Author:** ![alessuae](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@alessuae](https://forum.wixstudio.com/u/alessuae)\
**Post date:** [April 12, 2021, 11:19am UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/8 "2021-04-12T11:19:25Z")

</div>

Hi, I’m having the same issue, but in my case I’m trying to pass 2 values instead of 1.

When i console.log the page it shows me only 1 value passed and not the other. what might be causing that ? how can i fix it?

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [April 12, 2021, 1:03pm UTC](https://forum.wixstudio.com/t/getitem-returning-null-value/5362/9 "2021-04-12T13:03:22Z")

</div>

To pass 2-values instead of just one you could do it like that…

Main-page:

```javascript
import {local} from 'wix-storage';

$w.onReady(function () {
  $w('#button1').onClick(()=>{
      local.setItem("key1", "T-Shirt"); 
      local.setItem("key2", "Jacket"); 
      wixLocation.to("insertHereTheUrlOfTheSecondSite")//Navigation to second site
  });
});

```

Sub-page:

```javascript
import {local} from 'wix-storage';

$w.onReady(function () {
    $w('#button1').onClick(()=>{
        let x =local.getItem("key1"); 
        let y =local.getItem("key2"); 
        console.log(x), console.log(y)
    });
});

```
