Skip to content

Commit 485633b

Browse files
Merge pull request #32 from mbarbas11/show_club
Feature | get club data
2 parents d1be284 + 33fe7b5 commit 485633b

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

packages/backend/controllers/clubs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
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
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
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+
829
export default ClubPage;

0 commit comments

Comments
 (0)