import React, { useState, useEffect } from 'react' import fetch from 'unfetch' import Head from 'next/head' import Link from 'next/link' import LoadingIndicator from '../components/LoadingIndicator' import Sleep from '../components/sleep' import styles from './index.module.css' import links from '../data/links.json' import constants from '../constants.json' export default function Index() { const [motd, setMotd] = useState('loading...') const [userSpecificMotd, setUserSpecificMotd] = useState('loading...') const [news, setNews] = useState(null) useEffect(() => { console.info('Fetching news.json') fetch(`${constants.apiUrl}news.json`, { credentials: 'include', }) .then((resp) => { return resp.json() }) .then((data) => { setNews(data) }) }, []) useEffect(() => { console.info('Fetching data') fetch(`${constants.apiUrl}infos?motd=true`, { credentials: 'include', Accept: 'application/json', 'Content-Type': 'application/json', }) .then((resp) => { return resp.json() }) .then((data) => { setMotd(data.motd) setUserSpecificMotd(data.userSpecificMotd) }) }, []) const renderQAItem = (n, key) => { return (