about summary refs log tree commit diff stats
path: root/src/http.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.ts')
-rw-r--r--src/http.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/http.ts b/src/http.ts
index e66888c..2474eb5 100644
--- a/src/http.ts
+++ b/src/http.ts
@@ -23,7 +23,7 @@ class Http {
      * Set the CSRF token for subsequent requests.
      * @param {string} token
      */
-    static setCsrfToken(token) {
+    static setCsrfToken(token: any) {
         Http._csrfToken = token;
     }
 
@@ -34,7 +34,7 @@ class Http {
      * @param {Record<string, string> | null | undefined} params
      * @returns {string}
      */
-    static _appendParams(url, params) {
+    static _appendParams(url: any, params: any) {
         if (!params || Object.keys(params).length === 0) return url;
         const separator = url.includes('?') ? '&' : '?';
         const query = new URLSearchParams(params).toString();
@@ -47,15 +47,15 @@ class Http {
      * @param {Response} resp
      * @returns {never}
      */
-    static _throwHttpError(resp) {
+    static _throwHttpError(resp: any) {
         /** @type {HttpError} */
         const err = new Error(`HTTP ${resp.status}: ${resp.statusText}`);
-        err.status = resp.status;
-        err.responseText = '';
+        (err as any).status = resp.status;
+        (err as any).responseText = '';
         // Read error body asynchronously — don't block the throw
-        resp.text().then((t) => { err.responseText = t; }).catch(() => {
-            /* ignore */
-        });
+resp.text().then((t: any) => { (err as any).responseText = t; }).catch(() => {
+    /* ignore */
+});
         throw err;
     }
 
@@ -65,7 +65,7 @@ class Http {
      * @param {Record<string, string> | null} [params] - optional query parameters
      * @returns {Promise<HttpResponse>}
      */
-    static async get(url, params) {
+    static async get(url: any, params: any) {
         const urlWithParams = Http._appendParams(url, params);
         const resp = await fetch(urlWithParams, {
             method: 'GET',
@@ -86,7 +86,7 @@ class Http {
      * @param {Record<string, string>} body
      * @returns {Promise<HttpResponse>}
      */
-    static async post(url, body) {
+    static async post(url: any, body: any) {
         const params = new URLSearchParams(body);
         if (Http._csrfToken) {
             params.append('csrf_token', Http._csrfToken);
@@ -112,7 +112,7 @@ class Http {
      * @param {Record<string, string> | null} [params] - optional query parameters
      * @returns {Promise<HttpBlobResponse>}
      */
-    static async blob(url, params) {
+    static async blob(url: any, params: any) {
         const urlWithParams = Http._appendParams(url, params);
         const resp = await fetch(urlWithParams, {
             method: 'GET',
@@ -133,7 +133,7 @@ class Http {
      * @param {Record<string, string> | null} [params] - optional query parameters
      * @returns {Promise<HttpTextResponse>}
      */
-    static async text(url, params) {
+    static async text(url: any, params: any) {
         const urlWithParams = Http._appendParams(url, params);
         const resp = await fetch(urlWithParams, {
             method: 'GET',