-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(remix): Capture thrown fetch responses. (#10166)
Fixes: #10160 Potentially fixes: #10002 This PR adds support for extracting `header` data from thrown non-Remix responses (fetch responses) inside loaders / actions.
- Loading branch information
1 parent
9dbe87e
commit 14bf0a0
Showing
6 changed files
with
68 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/remix/test/integration/app_v1/routes/loader-throw-response/$id.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from '../../../common/routes/loader-throw-response.$id'; | ||
export { default } from '../../../common/routes/loader-throw-response.$id'; |
2 changes: 2 additions & 0 deletions
2
packages/remix/test/integration/app_v2/routes/loader-throw-response.$id.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from '../../common/routes/loader-throw-response.$id'; | ||
export { default } from '../../common/routes/loader-throw-response.$id'; |
24 changes: 24 additions & 0 deletions
24
packages/remix/test/integration/common/routes/loader-throw-response.$id.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { LoaderFunction } from '@remix-run/node'; | ||
import { useLoaderData } from '@remix-run/react'; | ||
|
||
export const loader: LoaderFunction = async ({ params: { id } }) => { | ||
if (id === '-1') { | ||
throw new Response(null, { | ||
status: 500, | ||
statusText: 'Not found', | ||
}); | ||
} | ||
|
||
return { message: 'hello world' }; | ||
}; | ||
|
||
export default function LoaderThrowResponse() { | ||
const data = useLoaderData(); | ||
|
||
return ( | ||
<div> | ||
<h1>Loader Throw Response</h1> | ||
<span>{data ? data.message : 'No Data'} </span> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters