Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lencioni
Copy link
Contributor

@lencioni lencioni commented Dec 5, 2025

When there is no content, calling response.json() results throws an error "Unecpected end of JSON input". We can avoid this by returning null when we receive a 204 status code. The cancel API endpoint behaves this way, so this should make the ride there a little smoother.

When there is no content, calling `response.json()` results throws an
error "Unecpected end of JSON input". We can avoid this by returning
null when we receive a 204 status code. The cancel API endpoint behaves
this way, so this should make the ride there a little smoother.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for handling HTTP 204 No Content responses in the makeHappoAPIRequest function. When a 204 status is received, the function now returns null instead of attempting to parse an empty response as JSON, which would throw an "Unexpected end of JSON input" error. This particularly benefits the cancel API endpoint which returns 204.

  • Added early return of null when response status is 204
  • Added test coverage for 204 No Content responses

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/network/makeHappoAPIRequest.ts Added status code check to return null for 204 responses before attempting JSON parsing
src/network/tests/makeHappoAPIRequest.test.ts Added test server endpoint and test case to verify null is returned for 204 responses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lencioni lencioni merged commit 5ca36a1 into main Dec 5, 2025
19 checks passed
@lencioni lencioni deleted the no-content branch December 5, 2025 15:56
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

Successfully merging this pull request may close these issues.

2 participants