서버
ordersGet = async (req, res, next) => {
try {
const ordersData = await this.managerService.ordersGet();
const imsi = [
{
id: 20,
content: "급해요",
status: 0,
customerId: 2,
goodsId: 1,
},
{
id: 10,
content: "급해요",
status: 0,
customerId: 2,
goodsId: 2,
},
];
res.render("management.ejs", { data: imsi });
} catch (err) {
console.log(err);
res.status(400).json({ errorMessage: "조회 실패" });
}
};
orderGet 메소드에서 데이터를 보내줍니다
클라이언트
<div>
<h1>주문관리</h1>
<table>
<th>주문번호</th>
<th>요청사항</th>
<th>주문현황</th>
<th>주문자번호</th>
<th>상품번호</th>
<th></th>
<% for(let i = 0; i<data.length; i++){ %>
<tr>
<td><%=data[i].id%></td>
<td><%=data[i].content%></td>
<td><%=data[i].status%></td>
<td><%=data[i].customerId%></td>
<td><%=data[i].goodsId%></td>
<td>
<button onclick="location.href='/management/order/<%=data[i].id%>'">
상세정보
</button>
</td>
</tr>
<% } %>
</table>
</div>
<% 안에 for문을 작성하고 { %> <% 로 닫아줍니다 }%>
클라이언트에서는 보이지 않습니다.
'내일배움캠프 노드 4기 > Today I Learned' 카테고리의 다른 글
[Nest.js] Express와 Nest.js (0) | 2023.02.09 |
---|---|
[EJS][JQuery] DB 정보 수정하기(이미지와 다른 데이터 분리) (0) | 2023.02.08 |
[TypeScript] 유틸리티 타입 (Utility Types) (0) | 2023.01.30 |
[TypeScript] Generic types - 2 (0) | 2023.01.27 |
[TypeScript] Generic types 제네릭 (0) | 2023.01.26 |