diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-12 09:19:43 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-12 09:19:43 +0100 |
commit | 6a0411142a381389adc0d7151a76fbbb33a81fa2 (patch) | |
tree | 3621b7ac8404c9514eca54940b313366752ea5d3 /pages/index.tsx | |
parent | 599108b21979039117ffe1de1817e71644a20fb4 (diff) |
no search results message + try to prevent repeat api requests
Diffstat (limited to 'pages/index.tsx')
-rw-r--r-- | pages/index.tsx | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index 2aa8243..719f9ea 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -127,19 +127,24 @@ export default function HomePage() { setLoggedIn(document.cookie.includes("token")); if (!loggedIn) return; // don't request user info if not logged in - var userInfoReq = await axios.request<userInfo>({ - method: "get", - url: `/api/user/info`, - headers: {"content-type": "application/json"} - }) - setUserInfo(userInfoReq.data); - - var userGamesReq = await axios.request<userGames>({ - method: "get", - url: `/api/user/games`, - headers: {"content-type": "application/json"} - }) - setGameInfo(userGamesReq.data); + + if (!userInfo) { + var userInfoReq = await axios.request<userInfo>({ + method: "get", + url: `/api/user/info`, + headers: {"content-type": "application/json"} + }) + setUserInfo(userInfoReq.data); + } + + if (!gameInfo) { + var userGamesReq = await axios.request<userGames>({ + method: "get", + url: `/api/user/games`, + headers: {"content-type": "application/json"} + }) + setGameInfo(userGamesReq.data); + } setGotData(true); })()}) |