I am trying to render a graph with data from an api rest, but it is not showing the values. I've tried to check the chartjs documentation and I can't find the error. can anybody help me? I'm using react, chart and axios.
import React, { useState } from "react";
import { Bar } from "react-chartjs-2";
import axios from "axios";
export default function ChartBar() {
const [dados, setDados] = useState({});
async function consultApi() {
let res = await axios.get(
"https://private-afe609-testefront.apiary-mock.com/anual-result"
);
Object.values(res.data).map(item => setDados(item));
}
console.log(dados);
consultApi();
return (
<div>
<Bar labels={[dados.label]} data={[dados.value]} />
</div>
);
}