Created
March 4, 2018 02:58
-
-
Save AlirezaAkbarix/5371d83a0aa3dcdc1a1fcd0aa2ce8e97 to your computer and use it in GitHub Desktop.
New req one
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
| // 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