Created
October 28, 2020 08:53
-
-
Save Gyvastis/7b22a883c3f6443e9656b6e27a29c02f to your computer and use it in GitHub Desktop.
Bing translate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const translate = text => fetch("https://www.bing.com/ttranslatev3", { | |
"headers": { | |
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36", | |
"content-type": "application/x-www-form-urlencoded", | |
}, | |
"body": `&fromLang=nb&text=${encodeURIComponent(text)}&to=en`, | |
"method": "POST", | |
"mode": "cors" | |
}) | |
.then(response => response.json()) | |
.then(json => json[0].translations[0].text); | |
translate('vann').then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment