提问人:Urmila Sirase 提问时间:9/30/2023 更新时间:9/30/2023 访问量:17
如何从数据库中检查订阅电子邮件的重复电子邮件,从数据库中获取所有电子邮件,并检查是否重复,然后发布该电子邮件
How to check duplicate email from database for subscription email get all email from database and check if duplicate or not then post that email
问:
我正在检查条件,但没有显示任何结果,我尝试从数据库中获取所有电子邮件,并检查它是否已经发布,并显示 toast 消息并发布该电子邮件
const onSubmit = async (data,e) => {
e.preventDefault();
let isDuplicate = false;
emailList.forEach((val) => {
console.log(val.Email);
console.log(data.Email);
if (val.Email === data.Email) {
isDuplicate = true;
}
})
if (!isDuplicate) {
axios
.post("https://localhost:44312/api/ClientSub/AddCSubscriber", data)
.then((res) => {
console.log(res);
toast.success("Successfully! Subscribed to the news letter");
})
.catch((error) => {
console.log(error);
});
reset();
}
else{
toast.success("You are already Subscribed");
}
}
useEffect(()=>{
getAllSubscribers();
},[])
答: 暂无答案
评论
data.Email
emailList
AddCSubscriber