1

私は暴動のAPIからいくつかのデータを取得しようとしてきましたが、問題があります:

これはコードの重要な部分です。

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");

モードを入れた場合: cors。CORS に問題がありますが、上記の例のようにすると、次のように表示されます。

champions.js:15 Uncaught (in promise) SyntaxError: Unexpected end of input
    at getUsuario (champions.js:15)

これは15行目です:

const { data } = await resp.json();
4

1 に答える 1