Skip to content

Commit

Permalink
Allow passing request config to VBase's getJSON method
Browse files Browse the repository at this point in the history
  • Loading branch information
mairatma committed Nov 8, 2023
1 parent da787a8 commit cfa7887
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/clients/infra/VBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
inflightUrlWithQuery,
InstanceOptions,
IOResponse,
RequestConfig,
RequestTracingConfig,
} from '../../HttpClient'
import {
Expand Down Expand Up @@ -83,8 +84,15 @@ export class VBase extends InfraClient {
}})
}

public getJSON = <T>(bucket: string, path: string, nullIfNotFound?: boolean, conflictsResolver?: ConflictsResolver<T>, tracingConfig?: RequestTracingConfig) => {
return this.getRawJSON<T>(bucket, path, nullIfNotFound, conflictsResolver, tracingConfig)
public getJSON = <T>(
bucket: string,
path: string,
nullIfNotFound?: boolean,
conflictsResolver?: ConflictsResolver<T>,
tracingConfig?: RequestTracingConfig,
requestConfig?: RequestConfig
) => {
return this.getRawJSON<T>(bucket, path, nullIfNotFound, conflictsResolver, tracingConfig, requestConfig)
.then(response => response.data)
}

Expand All @@ -93,7 +101,8 @@ export class VBase extends InfraClient {
path: string,
nullIfNotFound?: boolean,
conflictsResolver?: ConflictsResolver<T>,
tracingConfig?: RequestTracingConfig
tracingConfig?: RequestTracingConfig,
requestConfig?: RequestConfig
) => {
const headers = conflictsResolver ? { 'X-Vtex-Detect-Conflicts': true } : {}
const inflightKey = inflightURL
Expand All @@ -108,6 +117,7 @@ export class VBase extends InfraClient {
requestSpanNameSuffix: metric,
...tracingConfig?.tracing,
},
...requestConfig
} as IgnoreNotFoundRequestConfig)
.catch(async (error: AxiosError<T>) => {
const { response } = error
Expand Down

0 comments on commit cfa7887

Please sign in to comment.