From e8c5ab2b32d68c973d923e60ff20e39a7255fa4e Mon Sep 17 00:00:00 2001 From: Lautaro Dragan Date: Mon, 3 Aug 2020 07:54:04 -0300 Subject: [PATCH] [client] fix: avoid optional chaining since CRA has issues with it --- client/package.json | 2 +- client/src/ApiClient.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/package.json b/client/package.json index 7f9b315..91a8b7d 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@taros-minesweeper/client", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "dist/index.js", "scripts": { diff --git a/client/src/ApiClient.ts b/client/src/ApiClient.ts index 542d354..f074106 100644 --- a/client/src/ApiClient.ts +++ b/client/src/ApiClient.ts @@ -42,7 +42,8 @@ export const ApiClient = ({ url, accessToken }: ApiClientConfig): ApiClient => { ...contentTypeJsonHeaders, }, }) - if (response.headers.get('Content-Type')?.startsWith('application/json')) + const contentType = response.headers.get('Content-Type') + if (contentType && contentType.startsWith('application/json')) return response.json() else return response.text()