I'm new to using APIs, I think I am doing something wrong. I'm trying to return translated text from the Oxford Dictionary API:
translateBtn.addEventListener("click", () => {
let text = fromText.value.trim(),
translateFrom = selectTag[0].value,
translateTo = selectTag[1].value;
let app_id = "xxxxxxxx";
let app_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
let language = "en-gb";
let word_id = "example";
let apiUrl = 'https://od-api.oxforddictionaries.com/api/v2/entries/${language}/${word_id}';
fetch(apiUrl, {
method: "GET",
mode: "no-cors",
headers: { app_key: app_key, app_id: app_id },
})
.then((response) => response.json())
.then((data) => res.send(data));
});
I am getting the following error when I run this code. Have I done something incorrect? Thanks in advance!