I can't retrieve custom parameters passed to the router.

Hello fuse community! I’ve updated to version 0.25.5 and I have a problem with this.Parameter, I’ve changed some code lines from the hikr example. The problem is that I can’t retrieve custom parameters that I’ve passed to the router. Please tell me what am I doing wrong please?. These are my changes:

File: HomePage.js

...
function goToHike(arg) {
	console.log('Selected index: ' + Context.hikes.indexOf(arg.data)); // This return the index successfully
	
	var params = { "index": Context.hikes.indexOf(arg.data) };
	
	router.push("editHike", params);
}
...

File: EditHikePage.js

var Context = require("Modules/Context");
var Observable = require("FuseJS/Observable");

var params = this.Parameter;
var hike = Observable(Context.hikes.getAt(params.value.index));
...

You find the soliction for this? im trying to do the same. to make a fetch(url) from the hike params but with no success.

Someody know the issue?

i want to do it like this:

var api = hike.map(function(x) { return x.api; });
fetch("http://xxx.com/Api/gallery/" + api.value)....
module.exports = {
	name: name,
	api: api	
}

Return undefinied, but inside them method i can see the value of of api var.

I’ve been doing testing of several solutions, but nothing works. But!!! Actually, I’ve found that every javascript module executes once before you return the module object. Then, when a module is required you’ll get just the previous instance. Read the comments on code.

// The first time you require this module, Fuse runs javascript from here
var api = hike.map(function(x) { return x.api; });
fetch("http://xxx.com/Api/gallery/" + api.value)...
...
...
// The following lines returns the module's object 
// so, the next time you require the module Fuse will remenber the last instance of this module
// and only return the object
module.exports = {
    name: name,
    api: api    
};

Hi!

The parameter is asyncronously passed to your module. This means you cannot access this.Parameter.value immediately, you have to do that from inside the map function. This is the pattern:

this.Parameter.map(function(param) { 
    ... here use param ...

For example, to do an asynchronous fetch() call based on the parameter, do:

var data = this.Parameter.map(function(param) {
   var result = Observable(); 
    fetch(...).then(function(r) {
        result.value = r;
    })
    return result;
}).inner();

module.exports = { data: data }

Alternatively you can also use .onValueChanged:

var data = Observable();

this.Parameter.onValueChanged(module, function(param) {
   somethingAsync().then(function(r) {
       data.value = r;
   })
});

module.exports = { data: data }

Thanks you, this do the trick i wanted.
inside the then i have a for of data to display a pictures like this:

for(var i in data) {
   var item = data[i];			
   pictures.add(item);		
}

do you know how i can cache the result so i dont need to call the api again?, the pictures are cached after the first load, but i think this can be improved.

That’s not documented on Fuse documentation, I really appreciate your answer, thank you very much.