I have a mapping and in each mapping i want to get data in the file storage IPFS such as the name. Then I want to return the name on the interface. However, I get a "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." Can someone please help me? been trying to solve this for hours. Can't seem to understand why because I know that hName should be a string.
{this.props.hawkers.map((hawker, key) => {
const hawkerDetails = axios
.get("https://ipfs.infura.io/ipfs/" + hawker.profileHash)
.then(function (response) {
console.log("this is the data: ", response.data);
return response.data;
})
.catch(function (error) {
console.log(error);
});
const hName = hawkerDetails.then((details) => {
return hName;
});
return (
<>
<h4 style={{ display: "flex", marginTop: 20 }}>
<Link
to={`/hawkerInfo/${hawker.owner}`}
// state={{ chosenHawkerPk: hawker.owner }}
state={{ chosenHawkerPk: hawker }}
>
{hName}
</Link>
</h4>