I am using Node.js V12 with the the trello-node-api
package installed. I am able to find all the cards in a list but when I was looking through the json API for the card Link Here I am not able to find the correct title to check to see if the card is over due. I can find if the date was completed but not when the date turns red (Which is what I want) . I am very new with Javascript and I am not sure how to check for the red due date.
Pretty much to sum it up: I dont know how to check to see if a card is over due or not.
Here is the code that I came up with so far
Const trelloNode = require("trello-node-api")("privateinfo")
trelloNode.board.searchCards(boardID).then(function(response) {
response.forEach(element => {
if (element.idList === myListId2) {
var cardLink = element.shortLink;
if () {
//if the card shows the "red due date"
}
}
})
})
```
So I basiclly awnsered my own question.
What I did is added two if statements. The first one is checking to see if the card even has a due date. The second one is checking the current time against the due date. As I am new to javascript, this may not be the best way but this is my way.
var date1 = element.due;
var date4 = new Date("1970-01-01T00:00:00.000Z") // Reason is because cards that have no due date go back to this date so I have to exclude it.
var date2 = new Date(date1);
var date3 = new Date();
if (date2.getTime() != date4.getTime()){ // Checking to see if a card has a due date
if (date2.getTime() <= date3.getTime()){ // Checking for over due's