diff --git a/src/pages/index.js b/src/pages/index.js index c774a65..e2d11c2 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -11,14 +11,15 @@ import styles from './index.module.css' import links from '../data/links.json' import constants from '../constants.json' -export default function Index (props) { +export default function Index(props) { 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' + credentials: 'include', }) .then((resp) => { return resp.json() @@ -30,23 +31,25 @@ export default function Index (props) { useEffect(() => { console.info('Fetching data') - fetch(`${constants.apiUrl}motd`, { - credentials: 'include' + fetch(`${constants.apiUrl}infos?motd=true`, { + credentials: 'include', + Accept: 'application/json', + 'Content-Type': 'application/json', }) .then((resp) => { - return resp.text() + return resp.json() }) .then((data) => { - setMotd(data) + console.log(data) + setMotd(data.motd) + setUserSpecificMotd(data.userSpecificMotd) }) }, []) const renderQAItem = (n, key) => { return (