Commit 7b599b8c authored by John Lam's avatar John Lam

add new promo form working

parent 5207d84d
......@@ -7,19 +7,17 @@ export default function PromotionNewFormComponent () {
const { register, watch, handleSubmit, formState: { errors } } = useForm();
const onSubmit = (data) => {
console.log(data)
alert(JSON.stringify(data));
// fetch("localhost:8081/api/promotion", {
// method: "POST",
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify(data),
// })
// .then(res => res.json())
// .then(json => console.log(json))
// .catch(err => console.log(err.data))
fetch("http://localhost:8081/api/promos", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
})
.then(res => res.json())
.catch(err => console.log(err.data))
};
console.log(errors);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment