'I am creating a function that takes a filtered array and outputs a TextBlock in an adaptive card with the birthdays of users(Person and date of birth)
I am creating a function that takes a filtered array and outputs a TextBlock in an adaptive card with the birthdays of users (Person and date of birth), I wrote the code but I have an error: [onTurnError] unhandled error: Error: Payload is incorrect
this is a teamsBot file.js
if (invokeValue.action.verb === "event5") {
const res = await axios.get("https://365.sharepoint.com/sites/Manage/_api/Web/Lists(guid'')/Items", {
headers: {
'Authorization': 'Bearer token'
}
})
console.log(res);
let today = new Date();
// const tmp1 = res.data.value.filter(item => moment(item.field_4).format('MM') === moment(today).format('MM'));
// console.log(tmp1);
const tmp1 = res.data.value.map(val => {
return{
name: val.field_1,
bdate: new Date(val.field_4)
}
})
const currentMonth = (new Date()).getMonth()
const filtredEmployees = tmp1.filter(employee => {
return employee.bdate.getMonth() === currentMonth
})
console.log(filtredEmployees);
const card = cards.card1(tmp1);
await context.sendActivity({ attachments: [CardFactory.adaptiveCard(card)] });
return { statusCode: 200 };
}
and this is cards.js
const card1 = (tmp1) => {
return[
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content":{
"type": "AdaptiveCard",
"version": "1.4",
"body": [
tmp1.map(item => {
return(
{
"type": "TextBlock",
"text": item.bdate,
"wrap": true
}
)
})
],
"actions": [
{
"type": "Action.Execute",
"title": "На главную",
"verb": "hello",
"fallback": "Action.Submit"
}
]
}
}
]
}
module.exports.cards = {
card1: card1
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
