Skip to content

Commit

Permalink
make internal status as string on error
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsinriaz17 committed May 10, 2024
1 parent 34e6945 commit cab25bd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/helpers/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export class HttpClient {
get = async <T>(url: string, config = {}) => {
const response = await this.client.get<T>(url, config).catch((err) => {
if (err.response) throw { status: err.response.status, data: err.response.data }
throw { status: 500, data: "ECONNREFUSED", error: err }
// throw new Error('url:' + url + ' Error:' + err)
throw { status: "ECONNREFUSED", data: "ECONNREFUSED", error: err }
})
return response.data
}
Expand All @@ -23,7 +22,6 @@ export class HttpClient {
const response = await this.client.get<T>(url, config).catch((err) => {
if (err.response) throw { status: err.response.status, data: err.response.data }
throw { status: 500, data: "ECONNREFUSED", error: err }
// throw new Error('url:' + this.client.getUri() + url + ' ' + err)
})
const { data, status } = response
return { ...data, status }
Expand All @@ -32,8 +30,7 @@ export class HttpClient {
post = async <T>(url: string, data: any, config = {}) => {
const response = await this.client.post<T>(url, data, config).catch((err) => {
if (err.response) throw { status: err.response.status, data: err.response.data }
throw { status: 500, data: "ECONNREFUSED", error: err }
// throw new Error('url:' + url + ' Error:' + err)
throw { status: "ECONNREFUSED", data: "ECONNREFUSED", error: err }
})
return response.data
}
Expand Down

0 comments on commit cab25bd

Please sign in to comment.