
let wishList = res.data.wishList.map(v=> v.pid)
wishList = wishList.filter(v=>v===res.data.product.pid)
wishList = wishList.length ? true : false;
setBtnWish(wishList)
<button
type="button"
className={`btnStyle ${btnWish === false ? "btnWish" : "btnWishActive"}`}
onClick={addWishList}
>
<BsHeartFill color={btnWish === false ? "white" : "red"} size={size} />
<span>찜</span>
<span></span>
</button>
const addWishList = (e) => {
let data = { pid: info.pid, uid: userInfo.uid,btnWish }
axios({
method: 'post',
url: `http://localhost:8000/product/wish`,
data: data
})
.then(res => {
alert(res)
setDepth(!depth)
})
.catch((err) => { console.log(err) });
}
export async function addWishList(req,res) {
let {uid,pid,btnWish} = req.body
if(btnWish){
let result = await productsRepository.deleteWishList(uid,pid)
res.json(result)
}else{
let result = await productsRepository.addWishList(uid,pid)
res.json(result)
}
}

