2π
β
I think order
is an array, you need to loop through it
responseAdapter: ({ order, totalItems }) => {
const formatOrder = order.map(o => {
const orderCopy = JSON.parse(JSON.stringify(o))
orderCopy.orderDate = moment(o.orderDate).format('MMMM Do YYYY')
return orderCopy
})
return {
data: formatOrder,
count: totalItems
};
}
If youβre using ES6, there is shorter syntax
const formatOrder = order.map(o => {
const orderDate = moment(o.orderDate).format('MMMM Do YYYY')
return {...o, orderDate}
})
π€ittus
Source:stackexchange.com