mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-06-17 04:09:13 +08:00
20 lines
445 B
TypeScript
20 lines
445 B
TypeScript
import Client from './client';
|
|
import { APIError, InvalidToken } from './errors-ts';
|
|
import { Team } from '../types';
|
|
|
|
type Response = {
|
|
teams: Team[];
|
|
};
|
|
|
|
export default async function getTeams(client: Client) {
|
|
try {
|
|
const { teams } = await client.fetch<Response>(`/teams`);
|
|
return teams;
|
|
} catch (error) {
|
|
if (error instanceof APIError && error.status === 403) {
|
|
throw new InvalidToken();
|
|
}
|
|
throw error;
|
|
}
|
|
}
|