From ece19b77c7cd8d5a5f6db4aed68bda583f61895a Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Fri, 1 Jul 2022 01:50:09 +0530 Subject: [PATCH 1/2] fix undefined headers --- packages/api-client/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts index c75b39da3b38..002b0d8082f2 100644 --- a/packages/api-client/src/index.ts +++ b/packages/api-client/src/index.ts @@ -100,7 +100,7 @@ export class RestClient implements RestClientInterface { console.warn('Endpoint cannot contain query string', endpoint); } const queryParams = this.getParams(params); - return this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', options).then(function (response) { + return this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', { ...options }).then(function (response) { return response.json(); }); } @@ -141,7 +141,7 @@ export class RestClient implements RestClientInterface { }; delete: RestClientInterface['delete'] = (endpoint, params, options) => { - return this.send(endpoint, 'DELETE', options).then(function (response) { + return this.send(endpoint, 'DELETE', { ...options }).then(function (response) { return response.json(); }); }; From e67c82f21b282771c9ccae005390a6ad0defb952 Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Fri, 1 Jul 2022 22:03:33 +0530 Subject: [PATCH 2/2] requested improvements --- packages/api-client/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts index 002b0d8082f2..02a40b8a54f9 100644 --- a/packages/api-client/src/index.ts +++ b/packages/api-client/src/index.ts @@ -100,7 +100,7 @@ export class RestClient implements RestClientInterface { console.warn('Endpoint cannot contain query string', endpoint); } const queryParams = this.getParams(params); - return this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', { ...options }).then(function (response) { + return this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', options ?? {}).then(function (response) { return response.json(); }); } @@ -141,7 +141,7 @@ export class RestClient implements RestClientInterface { }; delete: RestClientInterface['delete'] = (endpoint, params, options) => { - return this.send(endpoint, 'DELETE', { ...options }).then(function (response) { + return this.send(endpoint, 'DELETE', options ?? {}).then(function (response) { return response.json(); }); };