From 6463193debb5b81102a7275d6dfda7dd91aaf5b0 Mon Sep 17 00:00:00 2001 From: Emily Liu Date: Wed, 2 Sep 2020 22:03:14 -0400 Subject: [PATCH] Student of the week page finished --- app/StudentWeek.js | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/app/StudentWeek.js b/app/StudentWeek.js index e76d459..91ba080 100644 --- a/app/StudentWeek.js +++ b/app/StudentWeek.js @@ -6,6 +6,7 @@ import { View, Text, StatusBar, + Image, } from 'react-native'; import { @@ -16,13 +17,46 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; +import { url } from './resources/fetchInfo.json' + class StudentWeek extends React.Component { + constructor(props) { + super(props) + this.state = { + isLoading: true + } + } + + componentDidMount() { + fetch(`${url}/api/en/student`,{ + headers: { + 'Cache-Control': 'no-cache' + }} + ).then((response) => { + return response.text(); + }).then((json) => { + this.setState({data: JSON.parse(json),isLoading:false}); + }).catch((error) => console.error(error)) + } + render() { - return ( - - - - ) + console.log(this.state.data) + if (this.state.isLoading) { + return + } else { + return ( + + {this.state.data.name} + + + Grade {this.state.data.year} + {"\n"}Hobbies: {this.state.data.hobbies} + {"\n"}Achievements: {this.state.data.achievements} + + + + ) + } } }