Di bawah ini adalah blok kode contoh menggunakan layanan translator azure:
fetch("https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=id", {
method: "POST",
headers: {
"Ocp-Apim-Subscription-Key": "PASTE_API_KEY_KAMU",
"Ocp-Apim-Subscription-Region": "southeastasia",
"Content-Type": "application/json"
},
body: JSON.stringify([
{ Text: "السلام عليكم ورحمة الله" }
])
})
.then(res => res.json())
.then(data => console.log(data[0].translations[0].text));