Hi
I’m sorry but I’m missing something fundamental here.
I’m trying to return a string ( an email address) in the response body from a JS API Service but the response body always shows ‘none’. Can you help explain whatI’m doing wrong with the following ?
class StdNodeService {
/**
-
@returns emailAddr
**/
testStandardNode() {
var unirest = require(‘unirest’);
var emailAddr;
unirest.get(‘https://www.truframe.co.uk/contact’)
.headers({‘Accept’: ‘application/json’, ‘Content-Type’: ‘application/json’})
.send({ “parameter”: 23, “foo”: “bar” })
.end(function (response) {
var startIndexOfStr = response.body.indexOf("mailto:");
var lengthOfMailTo = "mailto:".length
var startPosOfEMail = startIndexOfStr+lengthOfMailTo;
var endIndexOfStr = response.body.indexOf('\"', startPosOfEMail);
var emailAddr = response.body.substring(startPosOfEMail, endIndexOfStr);
console.log("::response Body string : string from mailto: = " + emailAddr);
});
return emailAddr;
}
}
Backendless.ServerCode.addService( StdNodeService );
Thanks
Paul