Skip to content

Commit

Permalink
response -> rawResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Tejas Kumar committed Aug 8, 2018
1 parent 4841466 commit 7742532
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/Get.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class ContextlessGet<TData, TError> 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) {
Expand Down
12 changes: 6 additions & 6 deletions src/Poll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,21 @@ class ContextlessPoll<TData, TError> 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,
}));
}
Expand Down

0 comments on commit 7742532

Please sign in to comment.