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

Remove json() utility #12146

Merged
merged 3 commits into from
Oct 18, 2024
Merged

Remove json() utility #12146

merged 3 commits into from
Oct 18, 2024

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Oct 17, 2024

This was deprecated with Single Fetch in Remix v2, and folks can always use Response.json() if needed.

  • First commit contains functional changes for easier review
  • Second/Third contain updates to unit and integration tests

TODO:

Copy link

changeset-bot bot commented Oct 17, 2024

🦋 Changeset detected

Latest commit: 73e49de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-config-routes-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

typeof value.headers === "object" &&
typeof value.body !== "undefined"
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had this duped in @remix-run/router and remix-run/server-runtime so we can share the router one now

Comment on lines -1315 to -1327
export const json: JsonFunction = (data, init = {}) => {
let responseInit = typeof init === "number" ? { status: init } : init;

let headers = new Headers(responseInit.headers);
if (!headers.has("Content-Type")) {
headers.set("Content-Type", "application/json; charset=utf-8");
}

return new Response(JSON.stringify(data), {
...responseInit,
headers,
});
};
Copy link
Contributor Author

@brophdawg11 brophdawg11 Oct 17, 2024

Choose a reason for hiding this comment

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

🫡

@@ -1,81 +0,0 @@
import {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything in here was duped in the router so we use those now

@brophdawg11 brophdawg11 marked this pull request as draft October 17, 2024 19:29
@brophdawg11 brophdawg11 force-pushed the brophdawg11/remove-json branch 2 times, most recently from 540e608 to 50c8eb5 Compare October 17, 2024 20:17
@brophdawg11 brophdawg11 force-pushed the brophdawg11/remove-json branch from 50c8eb5 to 73e49de Compare October 17, 2024 20:35
@brophdawg11 brophdawg11 marked this pull request as ready for review October 17, 2024 20:37
@brophdawg11 brophdawg11 merged commit 6bd8362 into dev Oct 18, 2024
8 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/remove-json branch October 18, 2024 14:17
Copy link
Contributor

🤖 Hello there,

We just published version 7.0.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 6.28.1-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 6.28.1 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 6.28.2-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants