在Google Recaptcha代码中使用swal库

时间:2019-05-22 21:18:58

标签: node.js recaptcha

我正在尝试创建Nodejs中的警报库“ Sweet Alerts”,此刻正在创建具有Google Recaptcha的联系表单。我想使用警报库向用户发送警报,告知他们他们尚未选择Recaptcha框,此刻使用了res.json,但是我尝试了底部的代码在前端呈现swal警报结束。目前没有任何工作,使用我尝试过的代码,我收到“设置后无法重新发送标头”错误,并且联系表格页面中断。

google recaptcha代码

if (req.body['g-recaptcha-response'] === undefined || req.body['g-recaptcha-response'] === '' || req.body['g-recaptcha-response'] === null) {
     res.json({ "responseCode": 1, "responseDesc": "Please select captcha" });

    }

我在尝试什么

 res.render('contact', Swal.fire({
        type: 'error',
        title: 'Oops...',
        text: 'Something went wrong!',
        footer: '<a href>Why do I have this issue?</a>'
      }));

0 个答案:

没有答案
相关问题