Airtable / airtable.js

Airtable javascript client
MIT License
2k stars 404 forks source link

No request sent when running inside aws lambda #336

Open Sebastiansc opened 1 year ago

Sebastiansc commented 1 year ago

I can't get the API to fetch anything when running inside aws lambda with a local aws SAM build. Other fetch requests requests work fine, including fetch requests to the airtable API endpoints, so there has to be something happening internally with airtable. I also get no logs or errors so it's been difficult to figure out what's happening.

Worth mentioning too that the js api works fine when running the lambda code directly with node from the terminal.

Here's my lambda:

export const lambdaHandler = async (event) => {
    var base = new Airtable({ apiKey: API_KEY }).base('appGssA8MXScTGkrW');

   // this works
    const res = await fetch(`https://api.airtable.com/v0/appGssA8MXScTGkrW/ICeators?maxRecords=3&view=Grid%20view`, {
        method: 'GET',
        headers: {
            "Authorization": `Bearer ${API_KEY}`
        }
    });

    if (res.ok) {
        const data = await res.json();
        console.log(data);
    }

    // this doesn't work
    const result = await base('Instagram creators').find('recuVrpcCxU5n6SGW', function (err, record) {
        if (err) { console.error(err); return; }
        console.log('Retrieved', record.id);
    });
}

To test this I'm running it in a local aws lambda application which fires up a Docker container

bmarcot commented 1 year ago

Same issue when running from a hardhat task.