I want to use the below given function called "transalte" in a JavaScript file. I have seen a answer on stackoverflow regarding this, but couldn't get what I had to do. Definitely the normal calling of function isn't working in this case
import queryString from "querystring";
import request from "request";
import { config } from "./config";
function translate(text: string, from: string, to: string) {
const requestOptions = getRequestOptions();
const params = {
"from": from,
"to": to,
"text": text
};
request.get(
config.speech.translateApi.endPoind + "/Translate?" + queryString.stringify(params),
requestOptions,
(error, response, body) => {
console.log(body);
}
);
}