Created
November 29, 2018 16:12
-
-
Save harryadel/52a3a0f1031fe0c5998c17f48d00be45 to your computer and use it in GitHub Desktop.
Meteor Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.call('sendName', 'John', (err, res) => { | |
if (err) { | |
return Bert.alert(err.reason, 'danger') | |
} | |
return Bert.alert('Name sent successfully!', 'success') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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