0

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);
    }
);
} 
Krish11
  • 9
  • 1
  • 1
    Does this answer your question? [How to call a typescript function from javascript?](https://stackoverflow.com/questions/56832308/how-to-call-a-typescript-function-from-javascript) – Connor Low Aug 12 '21 at 15:48
  • Just remove the types from the function declaration `function translate(text, from, to) {` – ludwiguer Aug 12 '21 at 15:49
  • ok but I need those later in my function – Krish11 Aug 12 '21 at 15:53

0 Answers0