Skip to content

Instantly share code, notes, and snippets.

@harryadel
Created November 29, 2018 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harryadel/52a3a0f1031fe0c5998c17f48d00be45 to your computer and use it in GitHub Desktop.
Save harryadel/52a3a0f1031fe0c5998c17f48d00be45 to your computer and use it in GitHub Desktop.
Meteor Methods
Meteor.call('sendName', 'John', (err, res) => {
if (err) {
return Bert.alert(err.reason, 'danger')
}
return Bert.alert('Name sent successfully!', 'success')
})
'sendName'(name) {
check(name, String)
try {
return HTTP.call('GET', 'http://example/xyz', {
params: { user: name }
});
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
throw new Meteor.Error('error-invalid-request', e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment