aboutsummaryrefslogtreecommitdiff
path: root/src/hypixelCached.ts
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 20:26:37 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 20:26:37 -0600
commitcf8b4923974e9f685209dc1218be20a06cc0f5c9 (patch)
tree8601d88ff265551fba9e2a05641981a505b9a281 /src/hypixelCached.ts
parentcd707234194b41df933a3a287b5fbec3657063d5 (diff)
downloadskyblock-api-cf8b4923974e9f685209dc1218be20a06cc0f5c9.tar.gz
skyblock-api-cf8b4923974e9f685209dc1218be20a06cc0f5c9.tar.bz2
skyblock-api-cf8b4923974e9f685209dc1218be20a06cc0f5c9.zip
fix caching issue
if you visited player/:user then player/:user/:profile it would error
Diffstat (limited to 'src/hypixelCached.ts')
-rw-r--r--src/hypixelCached.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index bf3124a..f98f6d6 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -8,6 +8,7 @@ import * as hypixel from './hypixel'
import { CleanPlayer } from './cleaners/player'
import { undashUuid } from './util'
import { CleanProfile, CleanFullProfile, CleanBasicProfile } from './cleaners/skyblock/profile'
+import { cleanProfileStats } from './cleaners/skyblock/stats'
// cache usernames for 4 hours
@@ -100,7 +101,11 @@ export async function fetchPlayer(user: string): Promise<CleanPlayer> {
path: 'player',
args: { uuid: playerUuid }
})
- playerCache.set(playerUuid, cleanPlayer)
+
+ // clone in case it gets modified somehow later
+ const cleanPlayerClone = Object.assign({}, cleanPlayer)
+ playerCache.set(playerUuid, cleanPlayerClone)
+
return cleanPlayer
}