Hey,
I’ve been trying to add an Array of Objects to my Product model schema but I get an error
CastError: Cast to Array failed for value when trying to save a model that contains a model...
and I noticed that items inside array for ex. “specifications” array behave like described below…
I send data from React component state like this
specifications: [{
value: 'some value',
label: 'label name'
},
{
value: 'some other value',
label: 'label other name'
}];
but In Express server I have data like this:
specifications: '[object Object], [object Object]';
and I can’t figure out how to solve it. Anyone knows how to approach the problem?
File with model Schema —> https://github.com/mdziadkowiec95/react-shop-app/blob/master/models/Product.js
File with the route --> https://github.com/mdziadkowiec95/react-shop-app/blob/master/routes/api/products.js
Compoenent in which I send post request with data —> https://github.com/mdziadkowiec95/react-shop-app/blob/master/client/src/views/ProductsPanel.js