File tree Expand file tree Collapse file tree 3 files changed +28
-7
lines changed
Expand file tree Collapse file tree 3 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -62,12 +62,12 @@ async function getClub(club_id) {
6262 . collection ( "clubs" )
6363 . doc ( club_id )
6464 . get ( ) ;
65-
6665 if ( doc . exists ) {
6766 //handling error iff ID does not exist..firestore doesnt catch doc not found error
6867 try {
6968 const club = await doc . ref . get ( ) ;
7069 return club . data ( ) ;
70+ console . log ( club . data ( ) )
7171 } catch ( error ) {
7272 console . log ( { error} )
7373 return null ;
Original file line number Diff line number Diff line change 1- const devBackendDomain = 'localhost:3000' // example
1+ const devBackendDomain = 'http:// localhost:3000' // example
22
3- export const clubEndpoint = `${ devBackendDomain } /club` // example
3+ export const clubEndpoint = `${ devBackendDomain } /club` // example
Original file line number Diff line number Diff line change 1- import React from 'react' ;
2- import styles from './ClubPage.module.css' ;
31
4- const ClubPage = ( ) => {
5- return < div className = { styles . root } > Club Page details</ div > ;
2+ import React , { useState , useEffect } from "react" ;
3+ import styles from "./ClubPage.module.css" ;
4+ //import { clubEndpoint, clubID } from "../../apis/endpoints";
5+
6+ const ClubPage = props => {
7+ const [ club , setClubData ] = useState ( { } ) ; //club is state where club data is stored
8+
9+ async function getClub ( ) {
10+ const { id } = props . match . params ;
11+ const res = await fetch ( `http://localhost:3000/club/${ id } ` ) ;
12+
13+
14+
15+ res
16+ . json ( )
17+ . then ( res => setClubData ( res ) )
18+ . catch ( err => err ) ;
19+ }
20+
21+ useEffect ( ( ) => {
22+ getClub ( ) ;
23+ } , [ ] ) ;
24+
25+ return < div className = { styles . root } > ClubPage</ div > ; //JSON.stringify(club) // {club.name}...
626} ;
727
28+
829export default ClubPage ;
You can’t perform that action at this time.
0 commit comments