Help

Discover what data silos are costing your org in our commissioned Forrester study. Learn more

Node-fetch ENOTFOUND to API (randomly occurs)

Topic Labels: API
623 3
cancel
Showing results for 
Search instead for 
Did you mean: 

Using node Airtable calls, when running a the fetch calls, randomly calls will return an error with

FetchError: request to https://api.airtable.com/v0/**************/Popular%20Searches%20Filter/recG77zPA5fNrb05z? failed, reason: getaddrinfo ENOTFOUND api.airtable.com

Doing basic call

base('Card Data').select({
    view: "Selected View",
    pageSize: 3,
}).eachPage(function page(records, fetchNextPage) {
 // code here
 fetchNextPage();
}, function done(err) {
    if (err) { console.error(err); return; }
});
3 Replies 3

Adding a little more context. I believe it is randomly returning the error on the table.find call

base('MOS Card Data').select({
    // Selecting the first 3 records in CMT: Client View:
    view: "Tech: All English MOS",
    pageSize: 3,
    // maxRecords: 1,
}).eachPage(function page(records, fetchNextPage) {

    console.log(records.length)

    records.forEach(function(record) {

        const table = base("Popular Searches Filter");
        const filters = record.get('Popular Searches Filter');
        const mosCode = record.get("mosCode");

        console.log('attempting to write out MOS code: ' + mosCode);
        console.log(filters)

        if (filters !== undefined && filters !== '') {

            filters.forEach((item, index) => {

                table.find(item, (err, rec) => {
        
                    try {
                        if (err) {
                            console.log(`***************** BAD MOS CODE: ${mosCode} **********************`)
                            console.error(err)
                            return
                        }
                        const term = rec.get("Search Term");
                        
                        const output = `${filterMap[term]}\n`;

                        console.log(`${mosCode}`)

                        fs.writeFile(`./mos-filters/${mosCode}.json`, output, { flag: "a+" }, (err) => {
                            if (err) throw err;
                        });

                    } catch (err) {
                        console.log(err)
                        
                    }
                });
        
                
        
            });
        }
        

        

    });

    fetchNextPage();

}, function done(err) {
    if (err) { console.log('**************** bad fetch ******************'); console.error(err); return; }
});

bumping, looking for a possible solution as this is core functionality to the API

I get the same error message.