it seems no matter what i do with the result it even as it comes back as an object because when I console.log it it prints [object object] however when I check it's typeof it's always a string, no matter what I do, I am trying to do JSON.parse immediately it breaks as it's already an object, just not identified as one for some reason.. if I do stringify and then parse it still stays a string as well.
This is what I get back: { "PPR": "Some text", "DDA": "another text" }
var rp = require('request-promise');
function myff(input, callback) {
const URL = "https://test.com";
try{
var options = {
method: 'GET',
uri: URL,
headers:{
'Content-Type': 'application/json',
'key': 'xxff'
},
};
rp(options)
.then(function (parsedBody) {
var a = parsedBody;
console.log("ParsedBody: " + a);
console.log("ParsedBody type : " + typeof a);
var stringy = JSON.stringify(parsedBody);
var parsy = JSON.parse(stringy);
console.log("type stringy: " + typeof stringy);
console.log("type parsy: " + typeof parsy);
callback(null, JSON.parse(parsedBody));
})
.catch(function (err) {
console.log(err)
});
}catch (e){
console.log(" erros:" + e);
}
}