Help

API Example Code gives rejected promise not handled error

1078 0
cancel
Showing results for 
Search instead for 
Did you mean: 
David_MacDouga1
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello. I’m writing a VSC extension, and using the example javascript code provided in the airtable api docs generated for my base. The code gets the records from airtable, but then logs an error. The extension doesn’t crash, but fails in

airtable.lib.run_action.js line 70 where it calls callback(base._checkStatusForError(resp.status)); with a rep_status of 200

Is this an airtable problem, or should I be adding reject code, catch code or similar?

rejected promise not handled within 1 second: TypeError: Cannot read properties of undefined (reading 'offset')
/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102
stack trace: TypeError: Cannot read properties of undefined (reading 'offset')
	at /Users/dave/Documents/Projects/vsc extensions/airtable-docs-ext/node_modules/airtable/lib/query.js:118:28
	at /Users/dave/Documents/Projects/vsc extensions/airtable-docs-ext/node_modules/airtable/lib/run_action.js:70:17
	at processTicksAndRejections (node:internal/process/task_queues:96:5)
const GLOSSARY_TABLE_ID = 'appgfA8v************';
const GLOSSARY_TABLE_NAME = 'Glossary';

getAllGlossaryRecords(tableID, tableName) {
    var base = new Airtable({apiKey: API_KEY}).base(tableID);
    let path = this.getPath(tableName);

    base(tableName).select({
        maxRecords: 20,
        view: "Base View"
    }).eachPage(function page(records, fetchNextPage) {
        records.forEach(function(record) {
            let content = record.get('Explanation');
            path = path + `/${record.get('Title')}.md`
            let result = macFiles.writeFileSync(path, content);
        });
        fetchNextPage();

    }, function done(err) {
        if (err) { 
            console.error(`Done Errer: ${err}`); 
            this._vscode.window.showInformationMessage('Done with errors!');
            return; 
        } else {
            this._vscode.window.showInformationMessage('Done!');
        }
    });
}
0 Replies 0