๐ ์ดํํ ์ฝ๋ฉ ์๊ฐ 4hour
๐๐ผ -
๐๐ผ -
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.get('/tacos', (req, res) => {
res.send('get /tacos response');
});
app.post('/tacos', (req, res) => {
console.log(req.body);
const { meat, qty } = req.body;
res.send(`ok here are your ${qty} ${meat} tacos`);
});
whether the data is sent through a form or through postman, we will have data potentially in our post request body and in express
easy way to access the data -> query string data
post request -> include a property called req.body
req.body -> contains key value pairs of data submitted in the request body. By default, it is undefined and it's populated(์ ๋ณด๊ฐ ์๋์ผ๋ก ์ฑ์์ง) when you use body-parsing middleware such as express.json or express.urlencoded
html์ด๋ json ๋ฑ ๋ค์ํ ํํ๋ก ๋ค์ด์ค๋ ์ ๋ณด๋ค์ express์์ ์ด๋ป๊ฒ ์ฒ๋ฆฌํ ์ง ๊ฒฐ์ ํด์ผ ํจ
๊ทธ๋์ ์ด๋ฌํ ์ ๋ณด๋ค์ ์ด๋ป๊ฒ parseํ ์ง express์๊ฒ ์๋ ค์ค์ผ ํจ, to parse form-encoded information from the request body
->app.use(express.urlencoded({ extended: true }));
app.use : running some code or some function on every single request doesn't matter what the pathe name is, what type of request is(get,post)
-> ๊ทธ๋ฌ๋ ์ด๊ฒ๋ง์ผ๋ก๋ json file์ parsinggํ์ง ๋ชป ํจ
app.use(express.json());
-> built-in middleware function, it parses incoming requests with json payloads(์ ์ก๋๋ ๋ฐ์ดํฐ)
representational state transfer
an architecural style for distributed hypermedia systems
Basically a set of guidelines for how a client + server should communicate and perform CRUD operations on a given resource
REST - idea, guideline, standards or principles
The main idea of REST is treating data on the server-side as resources than can be CRUDed. The most common way of approaching REST is in formatting the URLs and HTTP verbs in your applicaitons.
CRUD - create, read, update, delete or destroy
-> how can I go about implementing different routes to allow a user to perform CRUD on that resource(entity, tweet, or user or image or text message, mean anything -> expose or provide access to via HTTP)
GET / comments - list all comments
POST / comments - create a new comment
GET / comments/:id - get one comment (using ID)
PATCH / comments/:id - update one comment
DELETE / comments.:id - destroy one comment
์ฐธ๊ณ ๋งํฌ: ์ํํ ์ฝ๋ฉ์ฌ์
npm init -> package.json
npm i ejs -> node.modules
mkdir views public public/partials
https://www.reddit.com/r/dogecoin/comments/mrsx8e/hey_guys_i_just_became_a_dogecoin_millionaire/
hey_guys_i_just_became_a_dogecoin_millionaire -> slug, ์์ ์์ด๋๋ง์ผ๋ก๋ ํ์ด์ง ์ ๊ทผํ ์ ์์ง๋ง ์ฌ์ฉ์๊ฐ ๋ถ๋งํฌ๋ ๊ณต์ ํ ๋ ๋ ์๊ธฐ ์ฝ๋๋ก ํ๋ ๊ฒ
https://www.reddit.com/r/dogecoin/comments/myu51i/this_is_sad_news_please_do_take_a_moment_of/gvx89g8/ -> post id ๋ค์ comment id๋ ์๋ค ์ด๋ฅผ nested route๋ผ๊ณ ํจ
Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! thc concentrates for sale
We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. https://wmbet.casino/