Browse Source

Consume new first submitter endpoint

Kirk Trombley 5 years ago
parent
commit
5048a9853b
2 changed files with 11 additions and 1 deletions
  1. 2 1
      client/.env.development
  2. 9 0
      client/src/domain/apiMethods.js

+ 2 - 1
client/.env.development

@@ -1,2 +1,3 @@
-# REACT_APP_API_BASE=http://localhost:5000 # this can be uncommented to point to local server/app.py
+# REACT_APP_API_BASE=http://localhost:5000
+# above can be uncommented to point to local server/app.py
 REACT_APP_MONITOR_STORE=true

+ 9 - 0
client/src/domain/apiMethods.js

@@ -88,6 +88,15 @@ export const linkGame = async (gameId, linkedGame) => {
     }
 }
 
+export const getFirstSubmitter = async (gameId, round) => {
+    const res = await fetch(`${API_BASE}/game/${gameId}/round/${round}/first`);
+    if (!res.ok) {
+        return null; // API is that 404 means no submitter yet (or wrong game)
+    }
+    const { first } = await res.json();
+    return first;
+}
+
 export const joinGame = async (gameId, playerName) => {
     const res = await fetch(`${API_BASE}/game/${gameId}/join`, {
         method: "POST",