Created
October 26, 2022 22:37
-
-
Save tsprates/165f47efc5b7d1c1c9ab1aae0d0c9535 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Brazil's election for president 2022 | |
// Author: Thiago Prates | |
import fetch from "node-fetch"; | |
const url = "https://resultados.tse.jus.br/oficial/ele2022/544/dados-simplificados/br/br-c0001-e000544-r.json"; | |
const response = await fetch(url); | |
const json = await response.json(); | |
const results = json["cand"].reduce((acc, { /* candidato */ nm, /* porcentagem */ pvap }) => { | |
const pct = parseFloat(pvap.replace(/,/g, ".")); | |
const cand = | |
acc[nm] = { | |
"Porcentagem (%)": pct, | |
}; | |
return acc; | |
}, {}); | |
console.table(results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment