This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
)}` | |
); | |
} | |
} | |
}; |
Author
lordgape
commented
Oct 11, 2022
via email
That means you likely didn't implement your APiclient. Or Did you ?
…On Sun, Oct 2, 2022 at 5:25 PM devMunyi ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hi bro. I have tried using this code but doesn't seem to work. It is
returning an empty error object.Error: Oops something went wrong. Please
try again later {}
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/bd1963f3ec8266a0c22ff6bf0f6ceb9f#gistcomment-4322197>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUQ2PQKEQULOOUR6WQOOUDWBGZQZANCNFSM6AAAAAAQ26523E>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
I got it to work using axios instead. Thanks man
Anytime 😎
…On Tue, Oct 11, 2022 at 2:58 PM Samuel Munyi ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
I got it to work. Thanks man
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/bd1963f3ec8266a0c22ff6bf0f6ceb9f#gistcomment-4331462>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUQ2PXJ5WPZ2YMVMHAIMJDWCVW7BANCNFSM6AAAAAAQ26523E>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment