-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathairtable.js
More file actions
25 lines (20 loc) · 797 Bytes
/
airtable.js
File metadata and controls
25 lines (20 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const Airtable = require('airtable');
// Replace the placeholders with your own values
const base = new Airtable({ apiKey: 'YOUR_API_KEY' }).base('YOUR_BASE_ID');
const tableName = 'id';
// Add an event listener to the form submit button
document.getElementById("myForm").addEventListener("submit", function(event) {
event.preventDefault(); // prevent default form submission
// Get the form data
const formData = new FormData(event.target);
// Convert the form data to a JavaScript object
const data = Object.fromEntries(formData.entries());
// Insert the data into the table
base(tableName).create(data, function(err, record) {
if (err) {
console.error(err);
return;
}
console.log('Record created:', record.getId());
});
});