如何从数据库中检查订阅电子邮件的重复电子邮件,从数据库中获取所有电子邮件,并检查是否重复,然后发布该电子邮件

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

提问人:Urmila Sirase 提问时间:9/30/2023 更新时间:9/30/2023 访问量:17

问:

我正在检查条件,但没有显示任何结果,我尝试从数据库中获取所有电子邮件,并检查它是否已经发布,并显示 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();
},[])
CSS ReactJS asp.net 用户界面

评论

0赞 VDWWD 9/30/2023
这里缺少很多信息。从哪里来。控制台中是否存在错误,端点是否正常工作。data.EmailemailListAddCSubscriber
0赞 Urmila Sirase 9/30/2023
const [电子邮件列表,setEmailList] = useState([]);电子邮件列表变量和 getAllSubscribers 正在从服务器获取所有电子邮件
0赞 Urmila Sirase 9/30/2023
以下是 getAllSubscribers 函数 const getAllSubscribers = async() => { await axios.get('localhost:44312/api/ClientSub/GetAllCSubscriber') .then((res)=>{ console.log(res.data.data) setEmailList(res.data.data) }) }

答: 暂无答案