JSFiddle - React, Tailwind, and code Playground
JavaScript
var getInfo = () => {
fetch('https://jsonplaceholder.typicode.com/posts')
.then(response => response.json())
.then(json => {
const data = json.map(e => {
return e.userId
})
.reduce((cum, cur) => {
cum[cur] = ++cum[cur] || 1;
return cum;
}, {})
console.log(data)
/* fetch('https://jsonplaceholder.typicode.com/todos') */
})
}
getInfo()