Skip to content

Instantly share code, notes, and snippets.

@rclai
Last active January 30, 2023 15:20
Show Gist options
  • 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);
@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