I am working with airtable.com database. Here I am trying to display of a record of a particular table where table id is 101.
Everything works fine as records are displayed.
Here is my issue: I need to alert lastname and firstname of that record so I have added:
alert(record.lastname);
alert(record.firstname);
but nothing is alerted.
Here is the code that successfully displayed records:
function RecordList1() {
const base = useBase();
const table = base.getTableByNameIfExists('my-tablename-here');
// grab all the records from that table
const records = useRecords(table);
const recordSearch = records.filter(record => record.id == '101');
//alert(record.lastname);
//alert(record.firstname);
// render a list of records:
return (
<ul>
{recordSearch.map(record => {
return <li key={record.id}>{record.id} -- {record.lastname} ---- {record.firstname}</li>
})}
</ul>
);
}
filter
function returns an array so alert line should be like this. alert(recordSearch[0].lastname)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.