From c81e166d8cf94c196719d5625dbbd4c5cdb214ce Mon Sep 17 00:00:00 2001 From: Michael Freund Date: Thu, 10 Sep 2020 13:03:02 +0200 Subject: [PATCH] Handle errors when getting api-key like "API usage exceeded rate limit" in my case the request failt with "malformed api-key" and it did not detect the error, when fetching the api key --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index 6e1b6cc..c215ae8 100644 --- a/src/index.js +++ b/src/index.js @@ -59,6 +59,7 @@ function zulip(initialConfig) { if (!config.apiKey) { return accounts(config).retrieve().then((res) => { + if (res.error) return Promise.reject(res.msg) config.apiKey = res.api_key; return resources(config); });