在学习react的过程中卡住了
function tick() {
fetch('/time', {
method: 'GET',
}).then(function(response){
const element = (
<div>
<h1>北京时间</h1>
<h2>{response.text()}</h2>
</div>
);
ReactDOM.render(
element,
document.getElementById('example')
);
}).catch(function(error){
console.log(error.text());
});
}
setInterval(tick, 3000);
想练习fetch,每三秒刷新一次时间,目前能获取到时间,但是不会输出到页面上,代码response.text()这里应该是错了,但是怎么改啊