Changeset 4a64cf0 for reactapp/src/Pages
- Timestamp:
- 07/29/22 21:31:30 (2 years ago)
- Branches:
- main
- Children:
- 3a44163
- Parents:
- 7cb8c3c
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
reactapp/src/Pages/Professor.js
r7cb8c3c r4a64cf0 5 5 let params = useParams(); 6 6 7 let [professor, setProfessor] = useState(); 7 let [professor, setProfessor] = useState(null); 8 let [loaded, setLoaded] = useState(null); 8 9 9 10 useEffect(() => { 10 const url = "http://192.168.0.17:8080/professor/1";11 const url = `http://192.168.0.17:8080/public/professor/${params.professorId}`; 11 12 12 13 const fetchData = async () => { … … 15 16 const json = await response.json(); 16 17 setProfessor(json); 18 setLoaded(true); 17 19 } catch (error) { 18 20 console.log("error", error); … … 23 25 }, []); 24 26 25 return (26 <div>27 if (loaded) { 28 return ( 27 29 <div> 28 30 <div>{professor.professorName}</div> 29 31 <div>{professor.faculty.facultyName}</div> 32 <Outlet /> 30 33 </div> 31 <Outlet /> 32 </div> 33 ); 34 ); 35 } else { 36 return ( 37 <div> 38 <p>loading</p> 39 <Outlet /> 40 </div> 41 ); 42 } 34 43 } 35 44
Note:
See TracChangeset
for help on using the changeset viewer.