Hello? By any chance, can the Google Translate API v2 be used in the frontend?
Initially, I thought the Google Translate API v2 couldn't be used in the frontend due to CORS issues. However, when I input the code below into the browser, the API is being called normally.
I'm curious if it's okay to call the API directly from the browser from the beginning.
const url = 'https://translation.googleapis.com/language/translate/v2?key={{API_KEY}}';
const headers = {
'Content-Type': 'application/json; charset=utf-8',
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify({
"q": ["Hello world", "My name is Jeff"],
"target": "de"
}),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error(error));