Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. GlobUtil.prototype.sendSms = (number, msg, callback) => {
  2.  
  3. let options = {
  4. url: format(process.env.APPSMS, number),
  5. ca: fs.readFileSync(process.env.SMS_CERT_PATH),
  6. body: msg
  7. };
  8.  
  9. request.post(options, function(error, response, body) {
  10.  
  11. if (error) {
  12. log.error("Error calling sendSms: " + options.url);
  13. log.error("===== Error =====");
  14. log.error(error);
  15.  
  16. return callback(error);
  17. }
  18.  
  19. if (response.statusCode === 200) {
  20.  
  21. return callback(null, true);
  22. } else {
  23. result = JSON.parse(body)
  24. return callback(new Error(result));
  25. }
  26. });
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement