Skip to content

Instantly share code, notes, and snippets.

@lordgape
Created May 17, 2022 15:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lordgape/bd1963f3ec8266a0c22ff6bf0f6ceb9f to your computer and use it in GitHub Desktop.
const Formatter = require("./formatter");
const ApiClient = require("./api-client"); // Any API Client implementation. Can be axios
const Parser = require("./parser");
const url = `http://www.dneonline.com/calculator.asmx`;
module.exports = class Remote {
static async multipleTwoOperands(operandA, operandB) {
try {
let payload = {
Multiply: {
intA: operandA,
intB: operandB,
},
};
const headers = {
headers: {
"Content-Type": "text/xml; charset=utf-8",
SOAPAction: "http://tempuri.org/Multiply",
},
};
let args = Formatter.convertJsonToSoapRequest(payload);
let remoteResponse = await ApiClient.post(url, args, headers);
remoteResponse = await Parser.convertXMLToJSON(remoteResponse);
console.log(remoteResponse);
} catch (err) {
throw new Error(
`Oops something went wrong. Please try again later ${JSON.stringify(
err
)}`
);
}
}
};
@devMunyi
Copy link

devMunyi commented Oct 11, 2022

I got it to work using axios instead. Thanks man

@lordgape
Copy link
Author

lordgape commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment