I want to show only mapped URL instead of project URL mixing

Viewed 33

I'm new to react. I have a problem with url.

I get data from Github API through fetch request. Now I have to show only URL from API data but it shows me project url and data url mixed.

Here's the code which will simplify the problem.

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

this will update state with result data.

Here I destructured it from state.

const { repos } = this.state;

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

now I mapped repos and return JSX and show html_url from data. But the problem I'm facing is not showing url from data.

It shows like this

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

I copy this from chrome devtools. ("/profile/" is extra).

How can I remove this. Where am I mistaken?

Somebody help. Thanks in advance.

0 Answers
Related