So, I have two methods here for adding/updating a card on a Trello board. They are both declared in a class, with the updateWatchlistCard being declared before the second method addWatchlistCard. I am getting the following error in my code when I make a call to the updateWatchlistCard in addWatchlistCard: TypeError: undefined is not a function.
I'm not sure what exactly is wrong here or why it is doing this. I've tried rearranging the code, rewriting the function, and none of it has worked.
async updateWatchlistCard([cardData], card){
console.log('fired updatewatchlistcard');
//* Attempt to grab user data.
try{
var userId = await noblox.getIdFromUsername(cardData.Username);
var properUsername = await noblox.getUsernameFromId(userId);
}catch(error){
return false;
}
//* Adds the check to the card.
await Trello.addCommentToCard(card.id,
`**Moderator:** ${cardData.ModeratorName}:${cardData.ModeratorId}` +
`\n**Suspicion:** ${cardData.Suspiscion}` +
`\n**Evidence:** ${cardData.Evidence}` +
`\n**Comments:** ${cardData.Comments}`
);
return {value: '**Card updated successfully!**', cardName: card.name, cardUrl: card.url};
}```
``` async addWatchlistCard([cardData]){
// First search and see if the card already exists.
var cardExists = await this.getModerationCard(cardData.Username, cardData.WatchlistId, cardData.BoardId);
if(!cardExists){
//Tries getting new data for the card.
try{
var userId = await noblox.getIdFromUsername(cardData.Username);
var properUsername = await noblox.getUsernameFromId(Number(userId));
}catch(error){
return false;
}
// Data for card fields.
var cardTitle = (`${properUsername}:${userId}`);
var cardDesc = (`Moderator: ${cardData.ModeratorName}:${cardData.ModeratorId}` + `\nSuspected of: ${cardData.Suspicion}` + `\nEvidence: ${cardData.Evidence}` + `\nComments: ${cardData.Comments}`);
// Create the new card.
var newCard = await Trello.addCard(cardTitle, cardDesc, cardData.WatchlistId);
return {value: '**Card created successfully**', cardName: newCard.name, cardUrl: newCard.url};
}else{
console.log('got here.');
let response = this.updateWatchlistCard(cardData, cardExists);
return response;
}
} ```
Update: I figured out it had to do with the way I was writing the parameters in the updateWatchlistCard method. Thanks!