-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Remove json() utility #12146
Conversation
🦋 Changeset detectedLatest commit: 73e49de The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
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" | ||
); | ||
} |
There was a problem hiding this comment.
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
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, | ||
}); | ||
}; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
540e608
to
50c8eb5
Compare
50c8eb5
to
73e49de
Compare
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
This was deprecated with Single Fetch in Remix v2, and folks can always use
Response.json()
if needed.TODO:
types.ts
issue mentioned in https://github.com/remix-run/react-router/pull/12146/files#r1805311358