1脊框、根據(jù)id刪除產(chǎn)品
// 刪除產(chǎn)品
app.delete('/product/:id',async function(req,res){
// 1、先根據(jù)id查找到要刪除的產(chǎn)品
const product = await Product.findById(req.params.id);
// 2践啄、執(zhí)行刪除
await product.remove();
// 3浇雹、刪除成功后返回一個狀態(tài)
res.send({
success:true
})
})
2、在test.http中編寫delete請求屿讽,刪除產(chǎn)品55
image.png
image.png
image.png