summaryrefslogtreecommitdiff
path: root/frontend/src/serverHelper.ts
blob: 8565fd6470a4e586042f7a0e8a109c3f73521fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
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;
};