Silver Library (Archived)
Node.js EP 5 - routing 본문
반응형
To share the code contents of specific file (e.g. let app.js to share the code with init.js)
Need to add 'export default app;' to the origin source. So, it can literally export so!
'export default app;' is the code. Then import it as follows:
'import app from "./app";'
Now, here is all about 'routes'.
How to use router? Router is the file which contains many route.
1. To let it work as router (direction indicator), you need to export the const variable in the router.js file.
2. Then create app object as 'app.get("/user",)
3. However, change app.get to app.use("/user", userRouter); This is I am using the entire 'router'.
[So, 'Express Core Routing'. If I need to sit and do some revision, this is the part.]
'Personal DB > Unclassified record' 카테고리의 다른 글
Extra - What is res, req? next? (node.js + express) (0) | 2021.02.19 |
---|---|
Nodejs - EP 6 , MVC pattern (0) | 2021.02.19 |
nodejs EP 4 - middleware (0) | 2021.02.19 |
nodejs 로 영상 사이트 구현하기 - EP 3 (0) | 2021.02.19 |
Node.js 로 영상 사이트 구현하기 - EP2 (0) | 2021.02.19 |