Passing variables from one page to another and using it in the JavaScript file

On my homepage I display a list of categories

<Each Items="{categories.model}"> 
      <Rectangle Margin="5,10,5,10" CornerRadius="5" Padding="10" Clicked="{goToCategoryPage}">
      <quote.Text Value="{name}" Color="#fff"  />
      <SolidColor Color="#272727" />
      <WhilePressed>
             <Scale Factor=".95" Duration=".08" Easing="QuadraticOut" />
      </WhilePressed>
      </Rectangle>
</Each>

Here is the javascript function in my js file

function goToCategoryPage(arg) {
    var category = arg.data;
    router.push("category", category);
}

Now receiving and using this data in my js file is a problem

var cat = Observable();
var id = category.map(function(x) { cat = x.id; return x.id; });

function getEntry(){
    
   // i need to use the id set above in my fetch --- when I try to use it 
  //-- console.log(id) gives (observable) and console.log(id.value)  gives undefined.
  // I try to use cat too same problem
    
}

getEntry();

How do I get to use #id in the js function getEntry()

How do I pass variables and use them in javascript ?

The route parameter is available as an observable through this.Parameter. The pattern is basically;:

 var data = this.Parameter.map(function(param) {
       var res = Observable();
       fetch(...something based on param...).then(function(x) {
         res.value = .. something based on the result;
       });
       return res;
 }).inner();

You now have an observable data which contains the result of the fetch, based on the parameter.

Thanks a million Anders,

I have been having this issue for a very long time. Sometimes it worked the way I implemented. I will propagate this changes through out my app.

Thanks

Hallo i have watched fuse 's videos on youtube about the Reusable Components(https://www.youtube.com/watch?v=-jk3jNQzE4U

) and i’m trying to do the same. Since i have put the JavaScript part in another file, i’m trying to separate the variables and functions from the module.exports but i did not succeed and i’m having errors. As you can see on the uploaded file, the original Script is on the left and mine on the right side. Please can someone help me to transform it?