我用nodejs
我试图通过wordpress对其进行一些调用,所有请求都正常工作,但当我添加请求正文时,它被发送为空,我试图搜索问题所在,但没有找到任何有效的结果。
我是说如果我发送这个请求
$body = [
\'name\' => \'Pixelbart\',
\'email\' => \'pixelbart@example.com\',
"password" => "Pass#your!word"
];
$body = json_encode( $body, TRUE );
echo $body; // here the body is correctly populated
$res = wp_remote_post("http://localhost:3000/users",
array(
\'headers\' => array(
\'Origin\' => "http://localhost"
),
\'body\' => $body,
\'method\' => \'POST\',
\'data_format\' => \'body\'
)
);
在api方面,如果我尝试读取请求体,它是一个空JSON。因为我认为这是一个api问题,所以我尝试使用其他工具发送请求,但如果我使用postman以同样的方式发送请求,它就会正常工作。我错过什么了吗?我还试图删除所有插件和所有自定义导入,以便有一个清晰的环境,但同样的错误也发生了[如果从活动wordpress主题发送,来自javascript的ajax请求也会失败]