I’m trying to set up a couple of time-based charts on my dashboard. These are for an e-commerce platform. Basically, we want to see the number of orders received over time, and the revenue generated by these.
Expected behavior
Show time-based charts in the dashboard. I asked about time-based charts before in this forum, and I was told that the date and price should be at the root of the document in order for it to work. We have made these changes but we are now experiencing a different issue.
Actual behavior
I’m getting this error in the console: (0 , _moment.default)(...).tz is not a function
Here’s an order object.
/**
* Paste one or more documents here
*/
{
"status": "unfulfilled",
"cart": [{
"_id": {
"$oid": "5f784360f121c4d731af0cbd"
},
"productID": "B0199ANV1G",
"image": "https://images-na.ssl-images-amazon.com/images/I/514iLbGzE1L.jpg",
"title": "Huy Fong, Sriracha Hot Chili Salsa, 9 onzas botella (2 unidades) por Sriracha",
"price": "11.76",
"qty": 1,
"link": "https://www.amazon.com/-/es/Sriracha-Chili-onzas-botella-unidades/dp/B0199ANV1G",
"variant": "MAIN",
"supplier": {
"name": "Amazon"
}
}],
"userID": "xxxxxxxxxxxxxx",
"email": "someemail@gmail.com",
"phoneNumber": "+34555555",
"price": 21.75,
"payment": {
"txID": "xxxxxx",
"method": "Stripe",
"last4": "1111",
"brand": "MasterCard"
},
"shipping": {
"address": {
"_id": {
"$oid": "5f784360f121c481f9af0cbe"
},
"country": "Venezuela",
"firstName": "Carlos Enrique",
"lastName": "Suito",
"phoneNumber": "+34555555",
"street": "Ronda de Sant Antoni, 80",
"houseOrAptNumber": "Atico",
"city": "Caracas",
"state": "Distrito Capital",
"municipality": "Ciutat Vella",
"postCode": "08001",
"additionalInfo": "Tocar intercomunicador"
},
"courier": "Tiger shipping",
"method": "sea",
"weight": "1.37",
"dimensions": "0.33",
"total": {
"cost": 4.95,
"price": 10
},
"eta": "3 de noviembre",
"timeline": []
},
"creationDate": {
"$date": "2020-10-03T09:24:48.216Z"
},
"updatedOn": {
"$date": "2020-10-03T09:24:48.216Z"
},
"__v": 0
}
So basically, creationDate is of type Date, but for some reason it’s messing up forest’s charts. Any ideas how might I solve this problem?
Thanks!
Failure Logs
VM2935:1 POST https://xxxx.herokuapp.com/forest/stats/orders 500 (Internal Server Error)
"{"errors":[{"status":500,"detail":"(0 , _moment.default)(...).tz is not a function"}]}"
Context
- Package Version: 3.6.5
- Express Version: ~4.16.3
- Sequelize Version:
- Database Dialect: MongoDB
- Database Version: 4.2.8
- Project Name: Tranki