Search

에어테이블 연동

<script> // Replace these variables with your own PAT, Base ID, and Table Name const personalAccessToken = ''; // Your PAT token const baseId = 'appJQCUi52XSvIlMU'; // Your Airtable base ID const tableName = 'tbl80YhTLZNnt7Nfc'; // Your Airtable table name // API URL const apiUrl = `https://api.airtable.com/v0/${baseId}/${tableName}`; fetch(apiUrl, { method: 'GET', headers: { 'Authorization': `Bearer ${personalAccessToken}`, // Use PAT in the Authorization header 'Content-Type': 'application/json' } }) .then(response => { if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } return response.json(); // Parse the JSON response }) .then(data => { // Assuming you have a div with id 'resultContainer' to display the data const resultContainer = document.getElementById('resultContainer'); data.records.forEach(record => { const name = record.fields.Name; // Replace 'Name' with your field const div = document.createElement('div'); div.innerText = name; // Display the name in a new div resultContainer.appendChild(div); // Append to the container }); }) .catch(error => { console.error('Error fetching data:', error); // Handle any errors alert('Error fetching data: ' + error.message); }); </script> <div id="resultContainer"></div> <!-- This div will display the names -->
HTML
복사
// proxy.js const express = require('express'); const request = require('request'); const cors = require('cors'); const app = express(); const PORT = process.env.PORT || 3000; // Enable CORS app.use(cors()); app.use('/api', (req, res) => { const url = `https://api.airtable.com${req.url}`; // Airtable API URL const options = { method: req.method, headers: { 'Authorization': `Bearer YOUR_PERSONAL_ACCESS_TOKEN`, // Replace with your PAT 'Content-Type': 'application/json', }, body: req.method === 'POST' ? JSON.stringify(req.body) : null }; request(url, options, (error, response, body) => { if (error) { return res.status(500).send(error); } res.status(response.statusCode).send(body); }); }); app.listen(PORT, () => { console.log(`Proxy server is running on http://localhost:${PORT}`); });
HTML
복사
클라우드 펀딩 (보안으로 에어테이블 따로 관리해야 함)
탈리 utm ⇒ 에어테이블 ⇒ 에어테이블 수 ⇒ 홈페이지 반영
에어테이블 수: api 사용 records.length
cors 문제 -make 사용