Skip to content

Commit

Permalink
fix: url return 404
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Mar 7, 2024
1 parent 6e9b6d5 commit b84e36c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/3001-shop/pages/shop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ Shop.getInitialProps = async () => {
const timeout = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));

const fetchPromise = fetch('https://swapi.dev/api/people/1').then((res) =>
res.json(),
);
const fetchPromise = fetch('https://swapi.dev/api/people/1')
.then((res) => res.json())
.catch((err) => {
if (err instanceof Error) {
err.message = `fetchPromise failed: ${err.message}`;
}
console.error(err);
return Promise.resolve(fallback);
});

const fallback = {
name: 'Luke Skywalker',
Expand Down

0 comments on commit b84e36c

Please sign in to comment.