I'm trying to pass data through a URL in meteor. When I console.log the object it is empty, however, when i refresh the page, the object is displayed correctly in console.log.
I have a button in a google maps infoWindow which has an href to the page and with the parameters i want to pass over.
Js.
var infowindow = new google.maps.InfoWindow({
content: '<div id="infowin"><p>'+name+'"s storage </p>' +
'Space: '+space+
'<p>Price: '+price+'<div><a href="/request_storage?name='+name+'" class="btn btn-primary btn-lg" role="button">Request Storage</a></div>' +
});
In the template i try to access this data :
Js.
Template.storageRequest.onCreated(function () {
// Use this.subscribe inside onCreated callback
var GET = {};
var query = window.location.search.substring(1).split("&");
for (var i = 0, max = query.length; i < max; i++)
{
if (query[i] === "") // check for trailing & with no param
continue;
var param = query[i].split("=");
GET[decodeURIComponent(param[0])] = decodeURIComponent(param[1] || "");
}
Template.storageRequest.requestData = GET;
});
Any help is appreciated