Guard against JSON parsing errors
Open
- Dominant language
- JavaScript
- Stars
- 7
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Currently in the onSuccess handler, there is a catch function for reading the JSON response, that tries to read the stream again (via .text()) [here](https://github.com/Comcast/hypergard/blob/master/src/hyperGard.js#L508-L521).
This causes any possible parsing error to be masked by a `TypeError: body stream already read` since we are trying to read a stream twice.
The catch function should be refactored to guard against the body already being streamed `!response.bodyUsed.`
Contributor guide
Assessment
This issue has not been assessed yet.