From 2a65cddd09fcc0a21fec5bbc61bdacd606427e1c Mon Sep 17 00:00:00 2001 From: ayoshebby Date: Wed, 24 Apr 2024 13:46:40 +0100 Subject: [PATCH] AUT-2393: Resolve ts error enforcing to implement other missing properties of AxiosHeaders --- src/utils/error.ts | 4 ++-- src/utils/http.ts | 6 ++++-- yarn.lock | 12 ++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/utils/error.ts b/src/utils/error.ts index 30ed3c099..b4992ae55 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -9,8 +9,8 @@ export class BadRequestError extends Error { export class ApiError extends Error { private status?: number; - private data?: string; - constructor(message: string, status?: number, data?: string) { + private data?: unknown; + constructor(message: string, status?: number, data?: unknown) { super(message); this.data = data; this.status = status; diff --git a/src/utils/http.ts b/src/utils/http.ts index b3c4e73f8..55961d7ed 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -10,7 +10,9 @@ import { ApiResponseResult } from "../types"; import { HTTP_STATUS_CODES } from "../app.constants"; import { ApiError } from "./error"; -const headers: AxiosRequestHeaders = { +interface CustomAxiosRequestHeaders extends Partial {} + +const headers: CustomAxiosRequestHeaders = { Accept: "application/json", "Content-Type": "application/json; charset=utf-8", "Access-Control-Allow-Credentials": "true", @@ -97,7 +99,7 @@ export class Http { apiError = new ApiError( error.message, error.response.status, - error.response.data as string + error.response.data ); } else { apiError = new ApiError(error.message); diff --git a/yarn.lock b/yarn.lock index 528a79363..069d6fdaa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1816,12 +1816,12 @@ aws-sdk@^2.1356.0: uuid "8.0.0" xml2js "0.6.2" -axios@^0.28.0: - version "0.28.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.28.1.tgz#2a7bcd34a3837b71ee1a5ca3762214b86b703e70" - integrity sha512-iUcGA5a7p0mVb4Gm/sy+FSECNkPFT4y7wt6OM/CDpO/OnNCvSs3PoMG8ibrC9jRoGYU0gUK5pXVC4NPXq6lHRQ== +axios@^1.6.8: + version "1.6.8" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.8.tgz#66d294951f5d988a00e87a0ffb955316a619ea66" + integrity sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ== dependencies: - follow-redirects "^1.15.0" + follow-redirects "^1.15.6" form-data "^4.0.0" proxy-from-env "^1.1.0" @@ -2884,7 +2884,7 @@ flatted@^3.1.0: resolved "https://registry.npmjs.org/flatted/-/flatted-3.2.4.tgz" integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw== -follow-redirects@^1.15.0: +follow-redirects@^1.15.6: version "1.15.6" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==