Javascript 反应-使用wp_邮件发送电子邮件

Javascript 反应-使用wp_邮件发送电子邮件,javascript,jquery,reactjs,wordpress,Javascript,Jquery,Reactjs,Wordpress,我正在尝试在React中创建一个联系人表单,我想使用它通过我的Wordpress安装发送电子邮件。通常,如果我进行AJAX调用,我必须将提交函数的名称作为如下操作传入: jQuery.ajax({ type: 'POST', url: 'admin-ajax.php', data: { action: 'send_form' } }).done(function(response) { alert(response); }); 但是,由于我没有在React应用程

我正在尝试在React中创建一个联系人表单,我想使用它通过我的Wordpress安装发送电子邮件。通常,如果我进行AJAX调用,我必须将提交函数的名称作为如下操作传入:

jQuery.ajax({
    type: 'POST',
    url: 'admin-ajax.php',
    data: { action: 'send_form' }
}).done(function(response) {
    alert(response);
});
但是,由于我没有在React应用程序中使用jQuery,因此我正在使用
fetch

const res = await fetch('admin-ajax.php', {
    method: 'POST',
    body: JSON.stringify(this.state.values),
    headers: {
        "Content-Type": "application/json"
    }
});

我的问题是,如何在我的React调用中传递动作
send\u form

您可以在
正文
参数中附加以下内容:


body:JSON.stringify({…this.state.values,'action':'send_form'})
您可以将以下内容附加到
body
参数:

body:JSON.stringify({…this.state.values,'action':'send_form'})