Last active
November 7, 2022 18:57
-
-
Save randyphoa/e2222c76db8b6730d283750e6977fc5a to your computer and use it in GitHub Desktop.
Get accident data in React JS app
This file contains 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
const getAccidentData = (countries) => { | |
const payload = { | |
input_data: [{ | |
values: [{ | |
ACTION: "GET_ACCIDENT_DATA", | |
PARAMS: { COUNTRY: countries.map(x => x.toUpperCase()) } | |
}] | |
}] | |
}; | |
axios.post(URL, payload).then((response) => { | |
const fields = response.data.fields; | |
const values = response.data.values; | |
const data = values.map((x) => Object.fromEntries(zip(fields, x))); | |
setClusterData([]); | |
setPredictionData([]); | |
setAccidentData(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment