import React, { Component } from "react";
import { List, Header, Segment, Icon, Loader, Grid } from "semantic-ui-react";
import Moment from "react-moment";
import "moment/locale/es";
import { Link } from "@reach/router";
class Home extends Component {
constructor() {
super();
this.state = {
lastAgeThreads: [],
newThreadsList: [],
latestNews: [],
isLoaded: false
}
}
componentDidMount() {
fetch("https://bienvenidoainternet.org/cgi/api/lastage?limit=10")
.then((response) => { return response.json() })
.then((resource) => {
this.setState({
lastAgeThreads: resource["threads"]
})
});
fetch("https://bienvenidoainternet.org/cgi/api/newThreads?limit=10")
.then((response) => { return response.json() })
.then((resource) => {
this.setState({
newThreadsList: resource["threads"],
});
});
fetch("https://bienvenidoainternet.org/cgi/api/blotter")
.then((response) => { return response.json() })
.then((resource) => {
this.setState({
latestNews: resource["news"],
isLoaded: true
});
});
}
render() {
if (!this.state.isLoaded) {
return (
Cargando ...
)
}
const { newThreadsList, lastAgeThreads, latestNews } = this.state;
return (
{lastAgeThreads.map(thread =>
{thread.content}
{thread.board_fulln} ―
)}
{newThreadsList.map(thread =>
{thread.content}
{thread.board_fulln} ―
)}
{latestNews.map(n =>
)}
);
}
}
export default Home;