I have manage to get an API working for a product I have started to use, I can successfully run the below code and update a record in the api's database (I have removed all the api's soap xml code to make it look cleaner), I am trying to save the output as a variable so i can then process it in php,
I am a beginner to Javascript but I cant find much help on saving the output.
If someone could point me in the right direction I would be forever grateful,
I just need to console.log output in a variable rather than in the console.
var https = require("https");
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
'<soap:Header>' +
'</soap:Header>' +
'<soap:Body>' +
'</soap:Body>' +
'</soap:Envelope>';
var username = "";
var password = "";
var options = {
host: "",
port: 443,
method: "POST",
path: "",
// authentication headers
headers: {
'Content-Type': "text/xml; charset=utf-8",
'Content-Length': Buffer.byteLength(xml),
'Authorization': "Basic " + new Buffer(username + ":" + password).toString("base64"),
'SOAPAction': "",
'Accept': "application/json"
}
};
//The call
request = https.request(options, function (res) {
console.log("statusCode:", res.statusCode);
res.on("data", (d) => {
process.stdout.write(d);
});
});
request.on("error", (e) => {
console.error(e);
});
request.end(xml);