From 87f134c9f2714593890a530221df429122c4398b Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Tue, 10 Jun 2025 23:50:09 -0700 Subject: init --- frontend/src/serverHelper.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 frontend/src/serverHelper.ts (limited to 'frontend/src/serverHelper.ts') diff --git a/frontend/src/serverHelper.ts b/frontend/src/serverHelper.ts new file mode 100644 index 0000000..8565fd6 --- /dev/null +++ b/frontend/src/serverHelper.ts @@ -0,0 +1,12 @@ +import axios from "axios"; + +const SERVER_URL = "http://localhost:4000"; + +export const getWords = async (): Promise<[...(string[] & { length: 9 })]> => { + const words = (await axios.get(`${SERVER_URL}/random-words`)) + .data as string[]; + if (words.length !== 16) { + throw new Error(`Got invalid words ${words} from server`); + } + return words; +}; -- cgit v1.2.3-70-g09d2