-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrderCrud.jsx
40 lines (34 loc) · 946 Bytes
/
OrderCrud.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
function OrderCrud(props) {
function handleSubmit(e){
e.preventDefault();
const data = {}
data.tableNo=1
data.detailList = [
{menuNo:1,amount:1},
{menuNo:2,amount:2},
]
console.log(data);
let url = '/orders'
fetch( url , {
method: 'POST', //새로운값 추가시 POST
body: JSON.stringify(data),//추가할객체
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then((response) => response.json())
.then((json) => {
alert("주문등록완료")
console.log(json)
// navigate("/admin/list")
});
}
return (
<div>
<h1>주문등록</h1>
<button onClick={handleSubmit}>등록</button>
</div>
);
}
export default OrderCrud;