Skip to content

Commit 778be7d

Browse files
authored
fix: Handle object response from unstorage (#62)
1 parent 705e4df commit 778be7d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/stores/unstorage.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ export class UnstorageStore<
7373
async get(key: string): Promise<ClientRateLimitInfo | undefined> {
7474
const result = await this.storage
7575
.get(this.prefixKey(key))
76-
.then((value) =>
77-
value ? (JSON.parse(String(value)) as ClientRateLimitInfo) : undefined,
78-
);
76+
.then((value) => {
77+
if (typeof value === 'object') {
78+
return value as ClientRateLimitInfo;
79+
}
80+
81+
return value ? JSON.parse(String(value)) as ClientRateLimitInfo : undefined;
82+
});
7983

8084
return result;
8185
}

0 commit comments

Comments
 (0)