我无法在 Twilio 函数中获取收集输入小部件的值,我总是收到错误消息
此变量不起作用。让 val = event.widgets.Mortgage_info.Digits.value;
exports.handler = function (context, event, callback) {
const got = require('got');
got('https://cyan-sparrow-7490.twil.io/assets/mortgage.json').then (response =>{
const mort = JSON.parse(response.body);
let mortgageData = mort.feed.entry;
let mortgageIdTest = mort.feed.entry[900].gsx$mortgage.$t;
//Begin filter code
let val = event.widgets.Mortgage_info.Digits.value;
let index = mortgageData.findIndex(function(item, i){
return item.gsx$mortgage.$t === val
});
//End filter code
let mortgageSpecificData = mort.feed.entry[index];
let mortgageId = mort.feed.entry[index].gsx$mortgage.$t;
let borrowerName = mort.feed.entry[index].gsx$name.$t;
let lenderName = mort.feed.entry[index].gsx$lender.$t;
let recordDate = mort.feed.entry[index].gsx$recorddate.$t;
let lendAmount = mort.feed.entry[index].gsx$amount.$t;
let neededData = `Borrower ${borrowerName}\nYou loan with ${lenderName}\nClosed on ${recordDate}`
console.log(val);
console.log(index);
console.log(neededData);
callback(null,neededData);
});
};