Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Flexible example of Meteor.wrapAsync
// Thanks @trusktr
var requestSync = Meteor.wrapAsync(function(url, callback) {
request(url, function(error, response, body) {
callback(error, {response: response, body: body})
})
});
var result = requestSync("http://google.com");
console.log(result.response, result.body);
@alur222

This comment has been minimized.

Copy link

@alur222 alur222 commented Dec 13, 2016

i've been searching for this. Wew! Thanks! Didn't realize it was this easy! heheehe

@ssuio

This comment has been minimized.

Copy link

@ssuio ssuio commented Apr 4, 2017

This is really useful ! Had done research for this a whole night , now finally get it!

@luisbosch

This comment has been minimized.

Copy link

@luisbosch luisbosch commented Apr 27, 2017

Beautifully written :)

@aliEbraihmi

This comment has been minimized.

Copy link

@aliEbraihmi aliEbraihmi commented Jun 11, 2017

thank's a lot. that work for me!! :)

@chasset

This comment has been minimized.

Copy link

@chasset chasset commented Oct 3, 2017

Hi! How can you manage the error?

@JagdishUpadhyay

This comment has been minimized.

Copy link

@JagdishUpadhyay JagdishUpadhyay commented Mar 27, 2019

thanks

@AndrewShapovalov

This comment has been minimized.

Copy link

@AndrewShapovalov AndrewShapovalov commented Jun 5, 2019

Thanks a lot! You saved my day.

@Vinlock

This comment has been minimized.

Copy link

@Vinlock Vinlock commented Sep 17, 2020

Hi! How can you manage the error?

I believe you would just try/catch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment