'post api pblm in backend
const newItem = { name, price, img, detail, email }
fetch("http://localhost:5000/add", {
method: "POST",
header: {
"content-type": "application/json"
},
body: JSON.stringify(newItem)
})
.then(res => res.json())
.then(data => {
if (data.acknowledged === true) {
toast.success('Product add Successfully')
event.target.reset()
return;
}
})
my code does not work. I want to create a post api in my backend server. I send post request from my client side but doesn't work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|