Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Issue 27 return empty object on 204 responses #28

Merged
merged 1 commit into from
Apr 20, 2023

Conversation

nholik
Copy link
Contributor

@nholik nholik commented Apr 20, 2023

Return {} for 204 responses

Changes

This adds a check so that if the response code is 204, then an empty object is returned rather than attempting to parse the missing content. See #27 for further detail

How to Review

A response with a 204 status code and no body will return {} in the data field. Before the change, this will fail with a JSON parse error.

Checklist

  • Tests updated
  • README updated (N/A)

Addresses drwpow#27 by returning
an empty object for 204 responses to avoid json parsing errors while
keeping with current conventions for backward compatability.
@nholik nholik mentioned this pull request Apr 20, 2023
1 task
expect(response.status).toBe(204);

// assert error is empty
expect(error).toBe(undefined);
Copy link
Owner

Choose a reason for hiding this comment

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

Great test!

Copy link
Owner

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@drwpow drwpow merged commit ff3ae1b into drwpow:main Apr 20, 2023
@nholik nholik deleted the pr/return-empty-for-two-oh-four branch April 28, 2023 01:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants