Silver Library

Node.js EP 5 - routing 본문

Personal DB/Unclassified record

Node.js EP 5 - routing

Silver Archmage 2021. 2. 19. 16:47

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";'

 

These are app objects

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.]

0 Comments
댓글쓰기 폼