diff --git a/src/http-client.ts b/src/http-client.ts index ccedc346d..32714145e 100644 --- a/src/http-client.ts +++ b/src/http-client.ts @@ -139,46 +139,54 @@ export class HttpClient { await this.request({ ...params, uri: this.apiUri(params.uri), - headers: this.headers, + headers: { ...this.headers, ...params.headers }, }), ) } - public async get(resource: string): Promise { + public async get(resource: string, extraHeaders: Headers = {}): Promise { return this.apiRequest({ method: 'GET', uri: resource, + headers: extraHeaders, }) } - public async put(resource: string, body: RequestBody): Promise { + public async put(resource: string, body: RequestBody, extraHeaders: Headers = {}): Promise { return this.apiRequest({ method: 'PUT', uri: resource, body: JSON.stringify(body), + headers: extraHeaders, }) } - public async post(resource: string, body: RequestBody): Promise { + public async post( + resource: string, + body: RequestBody, + extraHeaders: Headers = {}, + ): Promise { return this.apiRequest({ method: 'POST', uri: resource, body: JSON.stringify(body), + headers: extraHeaders, }) } - public async delete(resource: string): Promise { + public async delete(resource: string, extraHeaders: Headers = {}): Promise { return this.apiRequest({ method: 'DELETE', uri: resource, + headers: extraHeaders, }) } - public async download(resource: string): Promise { + public async download(resource: string, headers: Headers = {}): Promise { const res = await this.request({ method: 'GET', uri: this.apiUri(resource), - headers: this.headers, + headers: { ...this.headers, ...headers }, }) // checks for common errors, we don't care about the result, as we expect it to throw