summaryrefslogtreecommitdiff
path: root/src/headless/NodeHttpLib.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-04-07 13:58:55 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-04-07 13:58:55 +0530
commitfaba5e9db8e0d1fdc4845de6b504b4e2ea3ca72b (patch)
tree53bbc26d9e5d16e168e682ce808461a395e00f45 /src/headless/NodeHttpLib.ts
parentfb2e2f89935240666de66e4b2c11125cb3b2943d (diff)
downloadwallet-core-faba5e9db8e0d1fdc4845de6b504b4e2ea3ca72b.tar.gz
wallet-core-faba5e9db8e0d1fdc4845de6b504b4e2ea3ca72b.tar.bz2
wallet-core-faba5e9db8e0d1fdc4845de6b504b4e2ea3ca72b.zip
finally make linter happy
Diffstat (limited to 'src/headless/NodeHttpLib.ts')
-rw-r--r--src/headless/NodeHttpLib.ts33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/headless/NodeHttpLib.ts b/src/headless/NodeHttpLib.ts
index 735d6b3cf..118fb9e96 100644
--- a/src/headless/NodeHttpLib.ts
+++ b/src/headless/NodeHttpLib.ts
@@ -16,6 +16,9 @@
SPDX-License-Identifier: AGPL3.0-or-later
*/
+/**
+ * Imports.
+ */
import {
Headers,
HttpRequestLibrary,
@@ -23,7 +26,7 @@ import {
HttpResponse,
} from "../util/http";
import { RequestThrottler } from "../util/RequestThrottler";
-import Axios, { AxiosResponse } from "axios";
+import Axios from "axios";
/**
* Implementation of the HTTP request library interface for node.
@@ -35,7 +38,7 @@ export class NodeHttpLib implements HttpRequestLibrary {
/**
* Set whether requests should be throttled.
*/
- setThrottling(enabled: boolean) {
+ setThrottling(enabled: boolean): void {
this.throttlingEnabled = enabled;
}
@@ -48,25 +51,21 @@ export class NodeHttpLib implements HttpRequestLibrary {
if (this.throttlingEnabled && this.throttle.applyThrottle(url)) {
throw Error("request throttled");
}
- let resp: AxiosResponse;
- try {
- resp = await Axios({
- method,
- url: url,
- responseType: "text",
- headers: opt?.headers,
- validateStatus: () => true,
- transformResponse: (x) => x,
- data: body,
- });
- } catch (e) {
- throw e;
- }
+ const resp = await Axios({
+ method,
+ url: url,
+ responseType: "text",
+ headers: opt?.headers,
+ validateStatus: () => true,
+ transformResponse: (x) => x,
+ data: body,
+ });
+
const respText = resp.data;
if (typeof respText !== "string") {
throw Error("unexpected response type");
}
- const makeJson = async () => {
+ const makeJson = async (): Promise<any> => {
let responseJson;
try {
responseJson = JSON.parse(respText);