I made a method “myMeteorMethod” on server witch gives back data in JSON file
On the client side a call method "myMeteorMethod"and connect it to “myMethodResult” session and thanks to “JSON.parse(result.content)” i take first value “[0].node.title” from “nodes” table
How to take all values from “nodes” table.
if (Meteor.isClient) {
Meteor.call('myMeteorMethod', function(error, result){
Session.set('myMethodResult', JSON.parse(result.content).nodes[0].node.title);
});
Template.hello.helpers({
counter: function(){
return Session.get('myMethodResult'); //
}
});
}
if (Meteor.isServer) {
Meteor.methods({
'myMeteorMethod': function() {
var result;
result = HTTP.get('http://www.s1054489.home-whs.pl/meteor/json');
return result;
}
});
Meteor.startup(function () {
// code to run on server at startup
});
}
<head>
<title>yaz</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
<template name="hello">
<button>Click Me</button>
<p>You've pressed the button {{counter}} times.</p>
</template>