From e0aeec5d5a213339836110e9f81bb34d144894cb Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 19 Oct 2024 12:48:57 +0100 Subject: [PATCH] log rate limit left --- projects/common/src/service/service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/common/src/service/service.ts b/projects/common/src/service/service.ts index 1a2f24f..e6890db 100644 --- a/projects/common/src/service/service.ts +++ b/projects/common/src/service/service.ts @@ -39,7 +39,11 @@ export default class Service { */ public async fetch(url: string): Promise { try { - return await ky.get(this.buildRequestUrl(!isServer(), url)).json(); + const response = await ky.get(this.buildRequestUrl(!isServer(), url)); + if (response.headers.has("X-RateLimit-Remaining")) { + this.log(`Rate limit remaining: ${response.headers.get("X-RateLimit-Remaining")}`); + } + return response.json(); } catch (error) { return undefined; }