From 77425325fcf43bf8ed614f680e581edef2067a7a Mon Sep 17 00:00:00 2001 From: Tejas Kumar Date: Wed, 8 Aug 2018 15:28:20 +0200 Subject: [PATCH] response -> rawResponse --- src/Get.tsx | 1 - src/Poll.tsx | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Get.tsx b/src/Get.tsx index 0a5f3329..5a15db74 100644 --- a/src/Get.tsx +++ b/src/Get.tsx @@ -171,7 +171,6 @@ class ContextlessGet extends React.Component< const request = new Request(`${base}${requestPath || path || ""}`, this.getRequestOptions(thisRequestOptions)); const response = await fetch(request); - const data = await processResponse(response); if (!response.ok) { diff --git a/src/Poll.tsx b/src/Poll.tsx index 235cee68..76114992 100644 --- a/src/Poll.tsx +++ b/src/Poll.tsx @@ -206,21 +206,21 @@ class ContextlessPoll extends React.Component< ...requestOptions.headers, }, }); - const response = await fetch(request); - const responseBody = await processResponse(response); + const response = await fetch(request); + const data = await processResponse(response); if (!this.isResponseOk(response)) { - const error = { message: `${response.status} ${response.statusText}`, data: responseBody }; - this.setState({ loading: false, lastResponse: response, data: responseBody, error }); + const error = { message: `${response.status} ${response.statusText}`, data }; + this.setState({ loading: false, lastResponse: response, data, error }); throw new Error(`Failed to Poll: ${error}`); } - if (this.isModified(response, responseBody)) { + if (this.isModified(response, data)) { this.setState(() => ({ loading: false, lastResponse: response, - data: resolve ? resolve(responseBody) : responseBody, + data: resolve ? resolve(data) : data, lastPollIndex: response.headers.get("x-polling-index") || undefined, })); }