首先,确保Airtable脚本中已经实现了正确的POST请求处理方式。示例如下:
const tableId = 'YOUR_TABLE_ID' const apiKey = 'YOUR_API_KEY'
let url = https://api.airtable.com/v0/${tableId}/TABLE_NAME
let options = {
method: 'POST',
headers: {
'Authorization': Bearer ${apiKey}
,
'Content-Type': 'application/json'
},
body: JSON.stringify({
// 这里是需要提交的数据
})
}
fetch(url, options) .then(response => response.json()) .then(data => { console.log(data); }) .catch(error => { console.error(error); });
然后,在使用API时,也需要保证请求的headers中包含正确的Content-Type。示例如下:
const express = require('express') const app = express() const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.post('/api', (req, res) => { console.log(req.body) // 这里是对POST数据的处理逻辑 })
app.listen(3000, () => {
console.log(Server is listening on port 3000
)
})
注意:上述示例中的"/api"应该根据实际情况进行修改,确保与API调用中的URL一致。