In my code, I get a JSON with a value (Example: 6647), and I would like to round it to only 1 decimal place.
In the code, I get the JSOn content by the call:
render(){
return(
<div className="container">
<div className="row">
<div className="col-md-12 col-lg-6 col-xl-3">
<div className = "row">
<div className = "info-box">
<span className = "info-box-icon logo-View">
<i className = "fa fa-tasks"> </i> </span>
<div className = "info-box-content">
<span className = "info-box-number">{this.state.data.pageViews}</span>
<span className = "info-box-text"> Page Views </span>
</div>
</div>
</div></div>
</div>
);
}
And the class:
componentDidMount(){
let URL = 'algumaURL'
fetch(URL)
.then(function(response) {
let data = response.json()
return data;
})
.then((json) => {
console.log('parsed json', json)
this.setState({data : json});
})
.catch(function(ex) {
console.log('parsing failed', ex)
})
}
JSON:
{"pageViews":13184}
PageViews value is randomized to every page refresh.