伙计们,我正在从智能合约中获取数据,它给出了一个很大的数字作为响应,我想将其转换为正常数字,以便我可以使用它来创建条形图。如何才能做到这一点?

这是我编写的代码片段,以便我可以将值存储在数组中:
//Creating candidatevoterarray for graph
for (var i =0; i<= 4; i++){
const temparray = this.candidatearray[i]
const count = temparray.voteCount
// this.candidatevotearray.push(count)
console.log(count)
}
Run Code Online (Sandbox Code Playgroud) 我已经在公共测试网上部署了一个智能合约,现在我尝试使用 ethers js 从前端连接到它。但是当我尝试获取该值时,它会在控制台中出现以下错误:
我使用 Angular 作为前端,这是我编写的代码:
declare let window: any;
import { Component, OnInit } from '@angular/core';
import { ethers } from 'ethers';
import addresses from '../../environment/contract-address.json'
import Election from '../../blockchain/artifacts/blockchain/contracts/Election.sol/Election.json'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'angvote';
public signer: any;
public electionContract: any;
public candidate : any;
public candidatesList:string[] | undefined;
constructor(){}
async ngOnInit(){
const provider = new ethers.providers.Web3Provider(window.ethereum);
window.ethereum.enable()
provider.on("network",(newNetwork: any, oldNetwork: any)=>{
if (oldNetwork){
window.location.reload();
} …Run Code Online (Sandbox Code Playgroud) 
代码看起来没问题,但是却出现了这个错误。它说 TypeError: Cannot read property 'length' of null in React Project. 我已经发布了下面的代码。我正在使用 React Js 来构建它。请帮助。
import React, {useEffect} from 'react'
import { Link } from 'react-router-dom'
import { useDispatch, useSelector } from 'react-redux'
import { Row, Col, ListGroup, Image, Form, Button, Card } from 'react-bootstrap'
import Message from '../components/Message'
import { addToCart } from '../actions/cartActions'
function CartScreen({ match, location, history }) {
const productId = match.params.id
const qty = location.search ? Number(location.search.split('=')[1]) : 1
const dispatch = useDispatch()
const cart …Run Code Online (Sandbox Code Playgroud) javascript ×2
angular ×1
ethereum ×1
ethers.js ×1
reactjs ×1
solidity ×1
typeerror ×1
typescript ×1