score:2

Accepted answer

if your data is an array of objects, you can use reduce to get the sum:

data.reduce((accumulator, currentvalue) => accumulator + currentvalue.available_funds, 0)

score:0

try this:

componentdidmount() {
    axios
        .get('http://localhost:3000/api/bills/1')
        .then(({ data }) => {
        var sum = 0;
        if(typeof data == 'object'){
            data.foreach(funds => {
                sum += parsefloat(funds.available_funds);
            });
        }
        this.setstate({
            availablefunds: sum,
            isloading: false
        });
    })
    .catch(err => {});
}

Related Query

More Query from same tag