-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathajax-call.js
32 lines (29 loc) · 1.1 KB
/
ajax-call.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const http = require('http');
const request = require('request');
let url = 'https://ldai5er9.wdf.sap.corp:44300/sap/opu/odata/SAP/Z_ASSET_MANAGEMENT_SRV/orderSet';
// let url = 'http://services.odata.org/TripPinRESTierService/People';
/*request(url, (err, res, body) => {
console.log('Error: ', err);
console.log('Response: ', res);
console.log('Body: ', body);
});*/
request({
url: url + '?$format=json',
headers: {
'Authorization': 'Basic TFVIQU5JV0FMOmUyZGhzZWFzaHVAQUtMJA==',
'Content-Type': 'application/json',
'x-csrf-token': 'Fetch'
}
}, (error, response, body) => {
if (!error && response.statusCode == 200) {
// csrfToken = response.headers['x-csrf-token'];
// console.log('CSRF Token: ' + csrfToken);
console.log('Error: ', error);
console.log('Response: ', response);
console.log('Body: ', body);
// res.json(body);
// bot.sendMessage(msg.chat.id, 'Error: ' + error);
// bot.sendMessage(msg.chat.id, 'Response: ' + response);
// bot.sendMessage(msg.chat.id, 'Body: ' + body);
}
});