hi, would you know give me the best procedure to return a collection to the client with a “Meteor.publish”?
server/Server.js
Posts = new Mongo.Collection(‘posts’);
`Meteor.publish(‘mypublish’, function() {
var self = this;
try {
var response = HTTP.get("http://linkforapicall-returnxml");
console.log(response.content);
Posts.insert(response);
this.ready();
return Posts.find();
}
catch(error) {
console.log(error);
}
});`
Client Side
Template.mytemplate.onCreated(function() { Meteor.subscribe('mypublish'); });
`
My Posts Collection
{{#each posts}}
{{/each}}
`
Thank you in advance for your help
db.posts
{ "_id" : "z4csinx9QLhMBKYcd", "statusCode" : 200, "content" : "<?xml version='1.0' encoding='utf-8'?>\n<evec_api version=\"2.0\" method=\"marketstat_xml\">\n <marketstat><type id=\"29668\">\n <buy><volume>1474</volume><avg>920928220.51</avg><max>1071000000.01</max><min>2300000.00</min><stddev>414107437.77</stddev><median>1051500000.01</median><percentile>1068717569.59</percentile></buy>\n <sell><volume>2485</volume><avg>1241428744.38</avg><max>2010000000.00</max><min>1086300000.02</min><stddev>116355540.29</stddev><median>1250000000.00</median><percentile>1099672004.46</percentile></sell>\n <all><volume>224152</volume><avg>8584.42</avg><max>16597485.32</max><min>0.30</min><stddev>3651679.64</stddev><median>1.99</median><percentile>1.00</percentile></all>\n </type></marketstat>\n </evec_api>", "headers" : { "server" : "nginx", "date" : "Thu, 31 Mar 2016 13:32:21 GMT", "content-type" : "text/xml; charset=UTF-8", "content-length" : "767", "connection" : "keep-alive", "vary" : "Accept-Encoding", "access-control-allow-origin" : "*" }, "data" : null }