Sending data to back-end

PussinSocks·2022년 7월 21일
0

CloneCoding

목록 보기
11/20
  • mixing variable with text
    #{variableName}
    Ex)
li #{video.rating}/5

mixing variable with attributes(href, class, id...)
`${variableName}` (inside backticks)
Ex)

a(href=`/videos/${video.id}`)=video.title

POST (POST Request)

POST is a http method that is used to manipulate the data and/or send data to back-end.

videoRouter.get("/:id(\\d+)/edit", getEdit);
videoRouter.post("/:id(\\d+)/edit", postEdit);

You can shorten this two get and post router into ->

videoRouter.route("/:id(\\d+)/edit").get(getEdit).post(postEdit);

app.use(express.urlencoded({ extended: true })); // understands and transform the value in the form into javascript object

req.body is a javascript representation of the value in the form

profile
On a journey to be a front-end developer

0개의 댓글