【问题标题】:'decodeUriComponent' is not defined no-undef'decodeUriComponent' 未定义 no-undef
【发布时间】:2021-10-16 01:03:52
【问题描述】:

由于某种原因,我收到一条错误消息“decodeUriComponent”。下面的代码可以查看它。首先,我认为我必须导入 decodeUriComponent 但我找不到任何需要导入它的相关信息。我走了大约 30 分钟,但我找不到任何导致此问题的东西。如果有人告诉我我需要做什么或我需要在我的代码中修复什么以便用 React 解决这个问题,我会非常感激

谢谢

    // https://develoepr.spotify.com/
// documentation/web-playback-sdk/quick-start/#
export const authEndpoint = "https://accounts.spotify.com/authorize";
const redirectUri = "http://localhost:3000/";
const clientId = "xxxxxxxxxxxxxxxxxxx";

const scopes = [
    "user-read-currently-playing",
    "user-read-recently-played",
    "user-read-playback-state",
    "user-top-read",
    "user-modify-playback-state",
];

export const getTokenFromUrl = () => {
    return window.location.hash
    .substring(1)
    .split("&")
    .reduce((initial, item) => {
        let parts = item.split("=");
        initial[parts[0]] = decodeUriComponent(parts[1]);

        return initial;
    }, {});
}

export const loginUrl = `${authEndpoint}?client_id=${clientId}&redirect_uri=${redirectUri}&scope=${scopes.join("%20")}&response_type=token&show_dialog=true`;

【问题讨论】:

    标签: reactjs spotify


    【解决方案1】:

    它是 decodeURIComponent(大写的 URI)而不是 decodeUriComponent

    【讨论】:

      猜你喜欢
      • 2018-06-09
      • 2018-10-02
      • 2021-05-26
      • 2021-06-17
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多