Skip to content

Instantly share code, notes, and snippets.

@AlirezaAkbarix
Created March 4, 2018 02:58
Show Gist options
  • Select an option

  • Save AlirezaAkbarix/5371d83a0aa3dcdc1a1fcd0aa2ce8e97 to your computer and use it in GitHub Desktop.

Select an option

Save AlirezaAkbarix/5371d83a0aa3dcdc1a1fcd0aa2ce8e97 to your computer and use it in GitHub Desktop.
New req one
// New Request class using request lib
const
request = require('request'),
reqOptions = {
method: 'POST',
url: 'https://api.telegram.org/botxxx/sendMessage',
body: {
chat_id: 73768632,
text: "Sending using new req"
},
json: true,
},
reqCallback = (error, response, body) => {
if (error || !(body && body.ok)) {
console.log(`Error: ${error} \nBody: ${body}`)
return;
}
console.log('body:', body);
};
sendRequest = () => {
request(reqOptions, reqCallback)
}
;
sendRequest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment