我只想显示映射的 URL 而不是项目 URL 混合

问题描述

我刚开始反应。我的网址有问题。

我通过 fetch 请求从 Github API 获取数据。现在我只需要显示 API 数据中的 URL,但它显示我混合了项目 url 和数据 url。

这是可以简化问题的代码

    fetch(
            `https://api.github.com/users/${username}/repos?per_page=${count}&sort=${sort}&client_id=${clientId}&client_secret=${clientSecret}`
          )
            .then((res) => res.json())
            .then((data) => {
              this.setState({ repos: data });
            })
            .catch((err) => console.log(err));

这将使用结果数据更新状态。

这里我从 state 中解构了它。

const { repos } = this.state;

<Link to={repo.html_url} className="text-info" target="_blank">
                {repo.name}
              </Link>

现在我映射了 repos 并返回 JSX 并从数据中显示 html_url。但我面临的问题不是从数据中显示 url。

显示是这样的

<a class="text-info" target="_blank" href="**/profile/**https://github.com/ahsandani001/amazon-clone">amazon-clone</a>

我从 chrome devtools 复制了这个。 (“/profile/”是额外的)。

我该如何删除它。我哪里弄错了?

有人帮忙。提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)