首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >div上Const的ReactJS值

div上Const的ReactJS值
EN

Stack Overflow用户
提问于 2019-06-20 08:11:48
回答 2查看 472关注 0票数 0

我是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“吗?致以问候。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56677420

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档