How to set data from app and get on inappbrowser using localstorage in ionic 4

I need a data from an app to inappbrowser. How can I get it.
I have tried it by using localstorage.

var html = '<h1> Hello World </h1>';
newWindow.on('loadstart').subscribe((event: InAppBrowserEvent) => {
newWindow.executeScript({ code: 'localstorage.setItem("dataKey",' + html + ')'  });
},
          error => {
            console.log("error", error);
          });

Here, I have tried to set data and I have rendered a html page on inappbrowser – test.html.
I want this stored data on that test.html which gets load in an inappbrowser.

``` ```

If any one has done this before please let me know.