Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always getting "[Unable to parse JSON body]" #119

Closed
nichwall opened this issue May 12, 2024 · 2 comments
Closed

Always getting "[Unable to parse JSON body]" #119

nichwall opened this issue May 12, 2024 · 2 comments

Comments

@nichwall
Copy link

I have not been able to get the JSON body to be parsed at all using wiretap (version 0.1.11 at the time of writing, but has been an issue since 0.1.1).

image

After some investigation, I think it is due to jsonBody instead of parsedBody always being used in the case statement (except for a Multipart body).

let jsonBody = '[unable to parse JSON body]';
let parsedBody = null;
try {
parsedBody = JSON.parse(req.requestBody);
JSON.stringify(parsedBody, null, 2)
} catch (e) {
jsonBody += ": " + e.message;
}
switch (exct) {
case ContentTypeJSON:
return html`${ct}
<pre><code>${unsafeHTML(Prism.highlight(jsonBody,
Prism.languages.json, 'json'))}</code></pre>`;

daveshanley added a commit that referenced this issue May 12, 2024
Fixed the broken JSON body parsing for requests. Not sure how it got borked. Also bumped deps
daveshanley added a commit that referenced this issue May 12, 2024
Fixed the broken JSON body parsing for requests. Not sure how it got borked. Also bumped deps
@daveshanley
Copy link
Member

You're right, this was messed up and has been fixed in v0.1.12

@nichwall
Copy link
Author

Confirmed working in v0.1.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants