-
export const loader = () => {
return { hello: 'world' }
} it works as expected. But I wanna know the different with export const loader = () => {
return json({ hello: 'world' })
} |
Beta Was this translation helpful? Give feedback.
Answered by
sergiodxa
Jun 16, 2022
Replies: 1 comment 2 replies
-
The json functions returns a Response object, and aside of data you can pass a ResponseInit as second argument to customize the status code and headers. When you don’t return a Response from the loader or action, Remix will pass your value to the json function and create the response for you. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
lili21
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The json functions returns a Response object, and aside of data you can pass a ResponseInit as second argument to customize the status code and headers.
When you don’t return a Response from the loader or action, Remix will pass your value to the json function and create the response for you.