|
@@ -10,4 +10,21 @@ export const getStatus = async () => {
|
|
|
} catch (err) {
|
|
|
return {status: err.message, version: null}
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+export const createGame = async (name, timer) => {
|
|
|
+ const res = await fetch(API_BASE + "/game", {
|
|
|
+ method: "PUT",
|
|
|
+ headers: {
|
|
|
+ "Authorization": `Name ${name}`,
|
|
|
+ "Content-Type": "application/json",
|
|
|
+ },
|
|
|
+ body: JSON.stringify({ timer }),
|
|
|
+ });
|
|
|
+ if (!res.ok) {
|
|
|
+ throw Error(res.statusText);
|
|
|
+ }
|
|
|
+ const { gameId } = await res.json();
|
|
|
+ return gameId;
|
|
|
+}
|
|
|
+
|