Consider code below:
componentDidMount(){
const loginEmail = localStorage.getItem('loginEmail');
const id = localStorage.getItem('id');
Promise.all([
fetch(`http://localhost:9000/api/users/view/${loginEmail}`) // first API
.then(value =>
value.json().then((res)=>{
this.setState({data: res.data});
})),
fetch(`http://localhost:9000/api/event/view/${id}`) // Second API
.then(value =>
value.json().then((res)=>{
this.setState({data: res.data});
})),
])
console.log(this.state.data) // cant get the result
.catch((err) => {
console.log(err);
});
}
This is what I am getting the response from console
So is it the way I do is wrong? By the way, My data from JSON api is in Object value.