(fixed) Meteor.wrapAsync with wrapping HTTP post request


#1

hello!

i’m still very new to Meteor and i hope you can help. on the server side, i ave a function that looks something like this:

loadMoreStuff = function(url) {
    HTTP.call('POST', url, 
        {params: settings.user}, 
        function(error, result) {
            if (error) {
                console.log(error)
            } else {
                var result = result.data.auth,
                    agencies = result.userAgencies,

                return agencies;
            }
        })
}

and also on the server side, i have a function that wraps the loadMoreStuff with Meteor.wrapAsync:

Meteor.methods({
        loadStuff: function() {
            var url = 'blahblahblah.com'
            var testFunc = Meteor.wrapAsync(loadStuff);
            var result = testFunc(url);
            return result;
        }
})

and on the client side, I call

Meteor.call('loadStuff', function(error, result) {
    //stuff
})

i can see that the HTTP post is returning the correct result, but for some reason in my loadStuff function on the server side, it is not returning the result from Meteor.wrapAsync.

thanks so much!


#2

If you don’t pass a callback function to HTTP.call then it’ll just act as a synchronous method, i.e. you don’t even need wrapAsync then!


#3

oops that was easy! haha GREAT THANK YOU :slight_smile:


#4

oops that was easy! haha great thank you so much!! :slight_smile: