Created
March 26, 2016 19:40
-
-
Save michaltakac/a870f2376da9d289da7b to your computer and use it in GitHub Desktop.
Server method for getting data through PHP script with Meteor
This file contains hidden or 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.methods({ | |
getCars: function() { | |
var url = 'http://example.com/my-php-script.php'; | |
var result = HTTP.post(url, {timeout:30000}); | |
if(result.statusCode==200) { | |
var respJson = JSON.parse(result.content); | |
console.log("response received."); | |
return respJson; | |
} else { | |
console.log("Response issue: ", result.statusCode); | |
var errorJson = JSON.parse(result.content); | |
throw new Meteor.Error(result.statusCode, errorJson.error); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment