XmlHttpRequest readyState Always 1?

Thanks for the feedback guys. Yes, the code runs in debug mode.

I modified the code to be synchronous, but now I get an error:
“EACCES: permission denied, open ‘.node-xmlhttprequest-sync-21191’”

Would be grateful for any ideas… feels like this should work to me… here’s the code:

Backendless.ServerCode.customEvent('chargeCustomerAndRecordDetails', function(req) {
 
 Backendless.Logging.setLogReportingPolicy( 1, 1 );
 var logger = Backendless.Logging.getLogger( "MyLogger");
 
 var config = {
    contentType: 'application/x-www-form-urlencoded',
    authorisationKey: '',
    authorisationValue: ''
 };


 var setContentType = function(value) {
    config.contentType = value;
 };


 var setAuthorisationHeaderKey = function(value) {
    config.authorisationKey = value;
 };


 var setAuthorisationHeaderValue = function(value) {
    config.authorisationValue = value;
 };


 var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
 var request = new XMLHttpRequest();


 var postData = encodeURI("username=test@email.com&api_key=12345e&from=test@email.com&from_name=Test&to=test@email.com&subject=Test&body_html=This is the <h1>HTML</h1>");


 setContentType('application/x-www-form-urlencoded');
 setAuthorisationHeaderKey('');
 setAuthorisationHeaderValue('');


 var elasticrequest = new XMLHttpRequest();


 elasticrequest.open('POST', 'https://api.elasticemail.com/mailer/send', false);
 elasticrequest.setRequestHeader('Content-type', config.contentType);
 if (config.authorisationKey!='' && config.authorisationValue!=''){
    elasticrequest.setRequestHeader(config.authorisationKey, config.authorisationValue);
 }


 elasticrequest.send(postData);
 
});

Gary