I tried doing the following:
request({
url: 'https://vdms-dev.clientsolve.com/evoDMDev/api_event.php',
headers: {
'Authorization': 'Bearer 71D50F9987529'
}
}, function(err, res) {
console.log(res);
});
The log is showing undefined but when I try it on Postman it seems to be working fine.
Any help would be appreciated!
Bearer tokens enable requests to authenticate using an access key, such as a JSON Web Token (JWT). The token is a text string, included in the request header. In the request Authorization tab, select Bearer Token from the Type dropdown list. In the Token field, enter your API key value.
This module lets you authenticate HTTP requests using bearer tokens, as specified by RFC 6750, in your Node. js applications. Bearer tokens are typically used protect API endpoints, and are often issued using OAuth 2.0.
Since your are calling https host (https://evodms-dev.clientsolve.com/evoDMSDev/api/api_event_all.php), request client will throws an error while doing SSL handshake,
thats why you got response as undefined
. Inorder to check the exact error response log the error console.error("Error Response : ", err)
Checkout this working snippet with error handling.err
Note: Now you will get Invalid Bearer Token error, Enter valid Bearer token
const request = require('request');
request({
url: 'https://evodms-dev.clientsolve.com/evoDMSDev/api/api_event_all.php',
headers: {
'Authorization': 'Bearer 71D50F9987529'
},
rejectUnauthorized: false
}, function(err, res) {
if(err) {
console.error(err);
} else {
console.log(res.body);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With