i've been trying to fetch some data from the riot's api, and I have a problem:
This is the important part of the code:
const getUsuario = async (name) => {
const resp = await fetch(`${APIRUL}${name}${apikey}`, {
method: 'GET',
mode: 'no-cors',
headers: {
"Content-Type": "application/json",
},
});
const { data } = await resp.json();
return data;
};
getUsuario("user-name");
If i put mode: cors. I have a problem with CORS, but if I have as the example above, it shows up this:
champions.js:15 Uncaught (in promise) SyntaxError: Unexpected end of input
at getUsuario (champions.js:15)
This is the line 15:
const { data } = await resp.json();