From be57d11438f1e2b359e1a1511f4a71e1ea42976b Mon Sep 17 00:00:00 2001 From: Roman Gafurov Date: Mon, 19 Aug 2024 05:11:56 +0400 Subject: [PATCH] style(http): return types --- src/lib/http/HttpManager.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/http/HttpManager.ts b/src/lib/http/HttpManager.ts index 43fc08b..889fad7 100644 --- a/src/lib/http/HttpManager.ts +++ b/src/lib/http/HttpManager.ts @@ -5,8 +5,8 @@ import axios, { AxiosError, AxiosInstance, + AxiosPromise, AxiosRequestConfig, - AxiosResponse, InternalAxiosRequestConfig } from 'axios'; import { URL, URLSearchParams } from 'url'; @@ -109,7 +109,7 @@ export class HttpClient { return client; } - private async handleError(client: AxiosInstance, err: unknown): Promise { + private async handleError(client: AxiosInstance, err: unknown): AxiosPromise { if (axios.isCancel(err) || axios.isAxiosError(err) === false || !this.shouldRetryRequest(err)) { return await Promise.reject(this.extractResponseError(err)); } @@ -262,12 +262,12 @@ export class HttpClient { /** * @param {string} slug The slug to get. * @param {{query?: Record & AxiosRequestConfig}} config Config. - * @returns {Promise} Returns a promise with the response. + * @returns {AxiosPromise} Returns a promise with the response. */ async get( slug: string, config?: { query?: Record } & AxiosRequestConfig - ): Promise { + ): AxiosPromise { return await this.client.get(this.getURL(slug, config?.query), config); } @@ -275,13 +275,13 @@ export class HttpClient { * @param {string} slug The slug to post. * @param {any} data Body data. * @param {{Record & RequestInit}} config Config. - * @returns {Promise} Returns a promise with the response. + * @returns {AxiosPromise} Returns a promise with the response. */ async post( slug: string, data: unknown, config?: { query?: Record } & AxiosRequestConfig - ): Promise { + ): AxiosPromise { return await this.client.post(this.getURL(slug, config?.query), data, config); } @@ -289,13 +289,13 @@ export class HttpClient { * @param {string} slug The slug to put. * @param {any} data Body data. * @param {{Record & RequestInit}} config Config. - * @returns {Promise} Returns a promise with the response. + * @returns {AxiosPromise} Returns a promise with the response. */ async put( slug: string, data: unknown, config?: { query?: Record } & AxiosRequestConfig - ): Promise { + ): AxiosPromise { return await this.client.put(this.getURL(slug, config?.query), data, config); } @@ -303,13 +303,13 @@ export class HttpClient { * @param {string} slug The slug to delete. * @param {unknown} data Body data. * @param {{Record & RequestInit}} config Config. - * @returns {Promise} Returns a promise with the response. + * @returns {AxiosPromise} Returns a promise with the response. */ async delete( slug: string, data: unknown, config?: { query?: Record } & AxiosRequestConfig - ): Promise { + ): AxiosPromise { return await this.client.delete(this.getURL(slug, config?.query), { ...config, data