3
const url = 'https://text-translator2.p.rapidapi.com/translate';
const options = {
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
'X-RapidAPI-Key': '0e0ba03caamsh21b40165f7b4d25p1fa302jsn22735ab99d70',
'X-RapidAPI-Host': 'text-translator2.p.rapidapi.com'
},
body: new URLSearchParams({
source_language: 'en',
target_language: 'id',
text: 'What is your name?'
})
};
try {
const response = await fetch(url, options);
const result = await response.text();
console.log(result);
} catch (error) {
console.error(error);
}
Comments
Post a Comment