I have an airtable base that I have read-only access to. I created a personal access token (PAT) and gave it read-only permission to that base.
I am using an angular app to display that data on a web interface, but I'm having difficulty successfully using the API. I have added both my airtable base and PAT to my environment variables, and have been using the auto-generated documentation to try and actually list the records. I continue to get a 'FetchError' detailed here:
FetchError: request to https://api.airtable.com/v0/{BASE}/{TABLE}?maxRecords=3&view=Grid+view failed, reason: self-signed certificate in certificate chain
at ClientRequest.<anonymous> (C:\EPandA\scorecard-metrics\code\backend\node_modules\node-fetch\lib\index.js:1505:11)
at ClientRequest.emit (node:events:513:28)
at TLSSocket.socketErrorListener (node:_http_client:502:9)
at TLSSocket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'SELF_SIGNED_CERT_IN_CHAIN',
code: 'SELF_SIGNED_CERT_IN_CHAIN'
}
When I go to the endpoint in the error I get this -
{"error":{"type":"AUTHENTICATION_REQUIRED","message":"Authentication required"}}
I've tried looking for what causes this, but have come up empty.
Here is my code:
const base = new Airtable ({ apiKey: process.env.AIRTABLE_API_KEY }).base(process.env.AIRTABLE_BASE);
base('OTD Form').select({
// Selecting the first 3 records in Grid view:
maxRecords: 3,
view: "Grid view"
}).eachPage(function page(records, fetchNextPage) {
// This function (`page`) will get called for each page of records.
records.forEach(function(record) {
console.log('Retrieved', record.get('Name'));
});
// To fetch the next page of records, call `fetchNextPage`.
// If there are more records, `page` will get called again.
// If there are no more records, `done` will get called.
fetchNextPage();
}, function done(err) {
if (err) { console.error(err); return; }
});
Any help or suggestions would be very appreciated - thank you!