javascript - Why's my GET request becoming unidentifiable?
问题描述
I want to eventually call functions from my php file onto my reactjs project so just to scratch the surface, I'm trying to to do a basic get request, but in the console, all I see is:
Here's it is [object Response]
Which isn't what I want to happen.
What am I doing wrong and how can I fix it?
Here's my js code:
import React, { Component } from 'react';
class Home extends Component {
componentWillMount() {
fetch("http://localhost/myProject/phpCalls/index.php", {
method: 'GET'
})
.then(res => {
console.log("Here's it is " + res);
});
}
render() {
return (
<h1>testing</h1>
);
}
}
export default Home;
Here's my php file:
header('Content-Type: application/json');
function hey() {
echo "Will I see this?";
}
$test = $_GET['do'];
if($test === "hey") {
hey();
}
解决方案
推荐阅读
- php - 卷曲请求超时失败
- php - 货币符号未使用 CodeIgniter 存储在 mySql 数据库中
- google-analytics - 事件数据,通过 Google 跟踪代码管理器发送,在 Google Bigquery 中不可见
- charts - 如何使用 Kendo Angular 创建垂直条形图?
- c# - Unity2D Input.touches 管理同时拖动 2 行
- ruby - How do I return false in RSpec as the expected result when checking if directory exist?
- qt - 如何正确地将 blob 数据插入表中
- php - 如何使用表单 symfony4 更新文件 .env
- javascript - 使用 DataTables 时,某些浏览器中的输入字段在刷新时不会清除
- spring - 如何将 ElasticSearch 7.0 版本与 Spring Boot 集成?