Created
April 21, 2019 19:32
-
-
Save marta-krzyk-dev/b447be40de47711f6e93883d3f040ab0 to your computer and use it in GitHub Desktop.
Node JS handler
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
_some_handler.post = function(data, callback){ | |
var reqDetails = {}; //Some details | |
var reqData = {}; //Some data | |
var req = https.request(reqDetails, function(res){ | |
if(200 == res.statusCode) { | |
callback(200, {'Message' : 'Success'}); | |
} else { | |
callback(500, {'Error' : 'Error! Please try again.' }); | |
} | |
}); | |
req.on('error', function(error){ | |
callback(500, {'Error' : 'Error from req.on(\'error\')! Please try again.' }); | |
}); | |
req.write(reqData); | |
req.end(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment