Skip to content
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

how to handle "not found (404)" page? #206

Open
Eserkani opened this issue Dec 27, 2021 · 1 comment
Open

how to handle "not found (404)" page? #206

Eserkani opened this issue Dec 27, 2021 · 1 comment

Comments

@Eserkani
Copy link

Hi
I want to add page 404. But I do not know if I did it right or not.
To do this, I add the following line.
{ path: "(.*)", load: () => import(/* webpackChunkName: 'not-found' */ "./not-found"), // action: () => '<h1>Not Found</h1>' },
I also designed not-found.js
The following code is the contents of my router.js:
`import UniversalRouter from 'universal-router';
import routes from './routes';
import { goTo } from './util/generalUtil';

export default new UniversalRouter(routes, {
resolveRoute(context, params) {
console.log("context.route 😍😍😍", context.route)
if (typeof context.route.load === 'function') {
return context.route
.load()
.then(action => action.default(context, params));
}
// else {
// console.log("😢😢😢😢😢")
// goTo("./not-found")
// }
if (typeof context.route.action === 'function') {
return context.route.action(context, params);
}
return undefined;
},
});
`
The following error occurs when testing:
image

@frenzzy
Copy link
Member

frenzzy commented Jan 3, 2022

It seems your not-found.js is missing export default part. Can you show your not-found.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants