axios calls mapping data from a different table – reactjs – and

this is not the client-side request job to handle your schema relations.

to access customer and product of a sale you should change your api.

when you request to Sales/GetSales GetSales should loop through every sale in your

database and for each sale find the relative customer by customerId inside sale object and

set it to result.

below we can see a simple example wrote in nodejs and mongoose.

// inside api

const sales = await Sale.find({}); => {
  sale.customer = await Customer.find({id: sale.customerId})

return sales.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top