Having trouble figuring out how to get this below code to work in javascript/react;
findSupplierName(supplierId) {
var object = this.state.supplierData.find(e => e.id === supplierId).name;
return object;
}
I have two API calls returning arrays, one contains orders while the other contains supplier information. I'm trying to find the supplier_id from the order array into a name from the supplier array.
<tbody>
{this.state.data.map((data, i) =>
<tr key={i}>
<td>{data.id}</td>
<td>{this.findSupplierName(data.supplier_id)}</td>
<td>{data.date}</td>
<td>{data.total}</td>
</tr>)}
</tbody>
I've tried using async/await but haven't been able to figure it out (Javascript newbie here). Most of the time the code fails as the find function takes a while to find the info.