【发布时间】:2019-03-14 00:39:03
【问题描述】:
我是 react js 新手,请参阅下面我在 react 中的 API 调用帖子
updateData = datas => {
axios
.post("http://localhost:8080/ReactAPI/post.php", datas)
.then(function(body) {
console.log(body);
})
.catch(function(error) {
console.log(error);
});
}
和PHP文件post.php代码如下:
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, X-Requested-With");
print_r($_POST);
?>
控制台我给出响应正文,如下所示:
{data: "Array↵(↵)↵", status: 200, statusText: "OK", headers: {…}, config: {…}, …}
我将下面给出的datas 传递给 i 方面作为响应
{id: "41", userId: "3672367892", fullName: "Subhash Patel"}
请帮我看看如何在 post.php 文件中接收datas 响应
【问题讨论】: