Replies: 1 comment 1 reply
-
Hiya! This is because the export default async function Home() {
let products: Products[];
try {
const token = await getAccessToken();
const response = await fetch('https://localhost:8000/v1/products');
if (!response.ok) {
throw new Error(response.statusText);
}
const products = response.json();
products = products.data;
}
catch (e) {
console.error(`Failed to fetch products: ${e}`);
}
if (!products.length) {
// Some error handling here, like `notFound()`.
}
// The rest of the code.
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I want to handle the unhandled runtime errors that says [ Server ] Error: fetch failed. Because, when I was reading the docs about the error handling, the throw doesn't work and basic return like return 'Error when fetching data X' too. It always return the same message [ Server ] Error: fetch failed, not the custom one
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions