강의 3주차 완료
insomnia에서 post요청으로 보낼때 계속 에러나는 현상이 있었다. 코드도 똑같이 복붙했는데 안되니 뭐지 했는데.
const express = require('express')
const app = express()
const port = 3000
const connect = require('./schemas/index');
connect();
const goodsRouter = require("./routers/goods");
app.use("/api", [goodsRouter]);
app.use(express.urlencoded({extended: false}))
app.use(express.json())
app.use(express.static('public'));
const express = require('express')
const app = express()
const port = 3000
const connect = require('./schemas/index');
connect();
app.use(express.json())//이거뭐냐 이거 위치 위로 하니까 실행 됨
const goodsRouter = require("./routers/goods");
app.use("/api", [goodsRouter]);
app.use(express.urlencoded({extended: false}))
app.use(express.static('public'));
app.use(express.json())
이 미들웨어 코드를 위로 옮기니 실행 되었다.
아직 미들웨어 라는 정의도 쉽게 가닥이 잡히지 않는다. 한번 쭈욱 강의를 듣고 다시 들으면서 개념을 정리할 필요가 있어 보인다.
/ 1 /
{
"_id" : ObjectId("61485196e10f64e6e14b1e41"),
"goodsId" : 1,
"name" : "맛있는 저녁",
"thumbnailUrl" : "https://recipe1.ezmember.co.kr/cache/recipe/2018/11/27/8b4c6ee660517265e47420b0fda202da1.jpg",
"category" : "food",
"price" : 15000,
"__v" : 0
}
/ 2 /
{
"_id" : ObjectId("6149357b9fc4dd1eacd6bad8"),
"goodsId" : 2,
"name" : "시원한 콜라",
"thumbnailUrl" : "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRk7JqMw7ZYZP4ZW136wcoMTmLzbrMIJzUWb1Dhu9cHwCPp0gA&usqp=CAc",
"category" : "drink",
"price" : 3000,
"__v" : 0
}
/ 3 /
{
"_id" : ObjectId("614936959fc4dd1eacd6badb"),
"goodsId" : 3,
"name" : "치킨",
"thumbnailUrl" : "https://pds.joins.com/news/component/htmlphoto_mmdata/201903/08/52cf07ea-c8da-4574-b0e9-21e0e3b31118.jpg",
"category" : "food",
"price" : 22000,
"__v" : 0
}
/ 4 /
{
"_id" : ObjectId("614936a19fc4dd1eacd6bade"),
"goodsId" : 4,
"name" : "맛있는 초밥",
"thumbnailUrl" : "https://gurunavi.com/ko/japanfoodie/article/sushi/img/sushi_01.jpg",
"category" : "food",
"price" : 17000,
"__v" : 0
}
/ 5 /
{
"_id" : ObjectId("614936ab9fc4dd1eacd6bae1"),
"goodsId" : 5,
"name" : "흑당 버블티",
"thumbnailUrl" : "https://t1.daumcdn.net/liveboard/dailylife/776f3aa618d64b789f9faedd95ce8272.jpg",
"category" : "drink",
"price" : 7000,
"__v" : 0
}
/ 6 /
{
"_id" : ObjectId("614936b59fc4dd1eacd6bae4"),
"goodsId" : 6,
"name" : "건강한 샐러드",
"thumbnailUrl" : "http://cdn.kormedi.com/news/article/__icsFiles/artimage/2018/08/22/c_km601/salad580.jpg",
"category" : "food",
"price" : 9000,
"__v" : 0
}
/ 7 /
{
"_id" : ObjectId("614936bd9fc4dd1eacd6bae7"),
"goodsId" : 7,
"name" : "고르곤졸라 피자",
"thumbnailUrl" : "https://lh3.googleusercontent.com/proxy/fT-LDTy8DX2DaDRHKnUwUEwOHWGTyTwoyWVIGa386lSWV3AdgmynrkqfJnj959M2GKYgd3sQ4EXXZ_f5AJ6eunn7PDNEAutBsjk2_UBwEwikbhafhXaz4F_siysxJ-4BkT7ITZ2kDU5OYA",
"category" : "food",
"price" : 19000,
"__v" : 0
}
/ 8 /
{
"_id" : ObjectId("614936cb9fc4dd1eacd6baea"),
"goodsId" : 8,
"name" : "베라 민초",
"thumbnailUrl" : "https://img1.daumcdn.net/thumb/R720x0.q80/?scode=mtistory2&fname=http%3A%2F%2Fcfile7.uf.tistory.com%2Fimage%2F9996DD4C5DD187AD021BFE",
"category" : "food",
"price" : 5000,
"__v" : 0
}
/ 9 /
{
"_id" : ObjectId("614936d59fc4dd1eacd6baed"),
"goodsId" : 9,
"name" : "맥주",
"thumbnailUrl" : "https://file.mk.co.kr/meet/neds/2019/03/image_readtop_2019_149823_15524352613667037.jpg",
"category" : "drink",
"price" : 7000,
"__v" : 0
}
/ 10 /
{
"_id" : ObjectId("614936e99fc4dd1eacd6baf0"),
"goodsId" : 10,
"name" : "말차 라떼",
"thumbnailUrl" : "https://cdn.imweb.me/upload/S201904245cbfeaeb57b7d/d7a1bead6a883.jpg",
"category" : "drink",
"price" : 7700,
"__v" : 0
}