Skip to content

Commit c8c8567

Browse files
committed
Await response.text() promise correctly
1 parent 1a8776c commit c8c8567

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/request.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export class Request {
6060
this.logger.debug(colorize("bold", JSON.stringify(responseJSON, null, 4)))
6161
}
6262

63-
private _logInvalidJSON(response : Response) : void {
64-
this.logger.debug(`Invalid Response JSON: ${response.clone().text()}`)
63+
private async _logInvalidJSON(response : Response) {
64+
this.logger.debug(`Invalid Response JSON: ${await response.clone().text()}`)
6565
}
6666

6767
private async _fetchWithLogging(
@@ -115,7 +115,7 @@ export class Request {
115115
try {
116116
json = await response.clone().json()
117117
} catch (e) {
118-
this._logInvalidJSON(response)
118+
await this._logInvalidJSON(response)
119119

120120
throw new ResponseError(response, `invalid json: ${json}`, e)
121121
}
@@ -139,7 +139,7 @@ export class Request {
139139
throw new ResponseError(response, "record not found")
140140
} else {
141141
// Bad JSON, for instance an errors payload
142-
this._logInvalidJSON(response)
142+
await this._logInvalidJSON(response)
143143
throw new ResponseError(response, "invalid json")
144144
}
145145
}

0 commit comments

Comments
 (0)