dvplut
dvplut

Reputation: 323

What are the ways to send data from server to client in Meteor?

I have async function on server side, that invoke from client and get data from some external sources by HTTP.call method. This is temporary data and I don't want put it in Mongo. Is a way to send this data to client except put in Mongo and do Meteor.publish?

This is piece of code:

Meteor.methods({
doRequest: function (partNumber) {
    check(partNumber, String);

    for (var i = 0; i < sources.length; i++) {
        sources[i].params.nr = partNumber;

        HTTP.call("POST", sources[i].url, { auth: sources[i].auth, params: sources[i].params }, requestHandler);
    }


    function requestHandler(err, res) {
        if (err) {
            throw new Meteor.Error("not-response", "Remote server not responding");
        }

        // need send array of objects to client
    }
}

});

Upvotes: 1

Views: 1687

Answers (1)

fardeem
fardeem

Reputation: 594

I see two ways to get this done:

  1. Use a client only collection. You can actually publish any data not only collection cursors. Check this out: http://meteorcapture.com/publishing-anything/

  2. [DEPRECATED] Use Meteor streams: http://arunoda.github.io/meteor-streams/

Upvotes: 3

Related Questions