Skip to content

Commit 57ceb53

Browse files
authored
fix(client): add type-safe return for getAccessToken (#2115)
1 parent 7bd8398 commit 57ceb53

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/client/helpers/get-access-token.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { AccessTokenError } from "../../errors";
22

3-
export async function getAccessToken() {
3+
type AccessTokenResponse = {
4+
token: string;
5+
scope?: string;
6+
expires_at?: number;
7+
};
8+
9+
export async function getAccessToken(): Promise<string> {
410
const tokenRes = await fetch(
511
process.env.NEXT_PUBLIC_ACCESS_TOKEN_ROUTE || "/auth/access-token"
612
);
@@ -23,6 +29,6 @@ export async function getAccessToken() {
2329
);
2430
}
2531

26-
const tokenSet = await tokenRes.json();
32+
const tokenSet: AccessTokenResponse = await tokenRes.json();
2733
return tokenSet.token;
2834
}

0 commit comments

Comments
 (0)