import { h, Component } from 'preact';
import { SingleRepo } from './singleRepo';
export class GithubRepos extends Component {
state = {
repos: [],
erroredOut: false,
};
componentDidMount() {
this.getGithubRepos();
}
getGithubRepos = () => {
fetch(`/github_repos`, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
credentials: 'same-origin',
})
.then((response) => response.json())
.then((json) => {
this.setState({ repos: json });
})
.catch(() => {
this.setState({ erroredOut: true });
});
};
render() {
const { repos, erroredOut } = this.state;
const allRepos = repos.map((repo) => (