I am using material-table with reactjs to create a data grid. I am filling the table with data from a previous HTTP request from an API and want to render the response of a second HTTP request in another column of that same table
render: rowData => this.Myfunction(rowData)
Myfunction(data){
axios.post('/api/status', {
payload:data
})
.then( res => {
if(res.data[0] != undefined){
return res.data[0].status
}
else{
return 'Null'
}
})
.catch(function (error) {
console.log(error);
});
}
}
The data I send to myFunction works properly for each row, but I cannot return the response I get from my request with axios.
I also tried
return axios.post('/api/reviews', {
payload:data
})
But I get an error:
Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.