Skip to content

Instantly share code, notes, and snippets.

@lordgape
Created May 17, 2022 15:16
Show Gist options
  • Select an option

  • Save lordgape/bd1963f3ec8266a0c22ff6bf0f6ceb9f to your computer and use it in GitHub Desktop.

Select an option

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
)}`
);
}
}
};
@lordgape

lordgape commented Oct 11, 2022 via email

Copy link
Copy Markdown
Author

@devMunyi

devMunyi commented Oct 11, 2022

Copy link
Copy Markdown

I got it to work using axios instead. Thanks man

@lordgape

lordgape commented Oct 11, 2022 via email

Copy link
Copy Markdown
Author

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