Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
234 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello all, I'm having trouble understanding what's wrong with this simple request. Any ideas?
const endpoint = 'https://api.cognitive.microsofttranslator.com/translate'
const location = 'eastus2'
const body = [{ "text":"What is wrong with me?" }]
const resp = await fetch(endpoint, {
method: 'post',
params: {
'api-version': '3.0',
'from': 'en',
'to': ['de', 'it']
},
headers: {
'Ocp-Apim-Subscription-Key': subscriptionKey,
'Ocp-Apim-Subscription-Region': location,
'Content-type': 'application/json',
},
body: body
})
const data = await resp.json()
console.log(JSON.stringify(data)
return new Response(JSON.stringify(data))
The "params" are not working, instead just use the URL! For instance:
https://api.cognitive.microsofttranslator.com/translate
to
https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=tr