首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >'decodeUriComponent‘没有定义-undef

'decodeUriComponent‘没有定义-undef
EN

Stack Overflow用户
提问于 2021-08-12 16:29:34
回答 1查看 19关注 0票数 0

由于某种原因,我得到了一个错误,说'decodeUriComponent‘。下面的代码是用来检查它的。首先,我认为我必须导入decodeUriComponent,但我找不到任何需要导入它的相关信息。我检查了大约30分钟,但我找不到任何导致此问题的原因。如果有人告诉我我需要做什么,或者我需要在代码中修复什么,以便用React修复这个问题,我将非常感谢。

谢谢

代码语言:javascript
复制
    // 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`;
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-12 16:31:25

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68761142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档