Skip to content

Instantly share code, notes, and snippets.

@rclai
Last active January 30, 2023 15:20
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save rclai/b9331afd2fbabadb0074 to your computer and use it in GitHub Desktop.
Save rclai/b9331afd2fbabadb0074 to your computer and use it in GitHub Desktop.
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
Copy link

alur222 commented Dec 13, 2016

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

@ssuio
Copy link

ssuio commented Apr 4, 2017

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

@luisbosch
Copy link

Beautifully written :)

@aliEbraihmi
Copy link

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

@chasset
Copy link

chasset commented Oct 3, 2017

Hi! How can you manage the error?

@JagdishUpadhyay
Copy link

thanks

@AndrewShapovalov
Copy link

Thanks a lot! You saved my day.

@Vinlock
Copy link

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