我是react的新手,我有一个简单的应用程序,如下所示:
我使用这个应用程序的目的是使用一个Spring Boot REST Service,并在我的react应用程序上打印数据json。
我通过以下教程实现了这一点:https://github.com/marmelab/restful.js/tree/master
但是现在我遇到了一个简单的问题,不知道如何在html标签上打印值,这是我的代码的一个例子:
import React from 'react';
import request from 'request';
import restful, { requestBackend } from 'restful.js';
const api = restful('http://someUrl/v1/mobile', requestBackend(request));
const totals = api.one('statusOrders',1); //organizationID = 1
totals.get().then((response) => {
const requestBody = response.body();
const totalsOrders = requestBody.data(); /*Need to print this on the <div>**/
})
class RestGps extends React.Component {
render(){
return(
<div className="container">
<p>Hello World</p>
//Here I want to print the values.
</div>
)
}
}
export default RestGps
const totalsOrders包含请求的值,请求结构如下:
{
"remissionOk": 109,
"remissionAlert": 5,
"remissionError": 17,
"remissionOutOfTime": 82
}
有人能告诉我如何在html上将此totalsOrders打印为我的文本"Hello World“吗?致以问候。
https://stackoverflow.com/questions/56677420
复制相似问题