We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1ae352e commit f5e9ae6Copy full SHA for f5e9ae6
src/APIManager.ts
@@ -17,7 +17,17 @@ export class SquareCloudAPIError extends Error {
17
}
18
19
export class APIManager {
20
- constructor(private apiKey: string) {}
+ constructor(private apiKey: string) {
21
+ this.testApiKey();
22
+ }
23
+
24
+ private async testApiKey() {
25
+ try {
26
+ await this.fetch('user');
27
+ } catch {
28
+ throw new SquareCloudAPIError('INVALID_API_KEY')
29
30
31
32
private async fetch(path: string, options: AxiosRequestConfig = {}) {
33
options.headers = {
0 commit comments