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()
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.
) 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?