I’m trying to create my first app with the functionality to copy records from 1 table to another.
I have been following examples here on the Record Picker and Spreadsheet importer: Airtable Scripting
I run into the error:
/Users/dev/.nvm/versions/node/v14.15.0/lib/node_modules/@airtable/blocks-cli/transpiled/src/builder/frontend/index.js: 'await' is only allowed within async functions (9:15)
If I remove await commands, then I run into:
ReferenceError: base is not defined
at HelloWorldApp (https://localhost:9000/__runFrame/bundle.js:59:21)
at renderWithHooks (https://localhost:9000/__runFrame/bundle.js:59844:18)
at mountIndeterminateComponent (https://localhost:9000/__runFrame/bundle.js:62524:13)
at beginWork (https://localhost:9000/__runFrame/bundle.js:63648:16)
at HTMLUnknownElement.callCallback (https://localhost:9000/__runFrame/bundle.js:45207:14)
at HTMLUnknownElement.e._wrapped (https://cdnjs.cloudflare.com/ajax/libs/rollbar.js/1.9.0/rollbar.nojson.min.js:1:13806)
at Object.invokeGuardedCallbackDev (https://localhost:9000/__runFrame/bundle.js:45256:16)
at invokeGuardedCallback (https://localhost:9000/__runFrame/bundle.js:45311:31)
at beginWork$1 (https://localhost:9000/__runFrame/bundle.js:68253:7)
at performUnitOfWork (https://localhost:9000/__runFrame/bundle.js:67204:12)
My code was modified from Hello World:
import {initializeBlock} from '@airtable/blocks/ui';
import React from 'react';
function HelloWorldApp() {
let sourceTable = base.getTable('Source');
let targetTable = base.getTable('Target');
let records = await sourceTable.selectRecordsAsync();
while (records.length > 0) {
await targetTable.createRecordsAsync(records.slice(0, 50));
records = records.slice(50);
}
return <div>All Done 🚀</div>;
}
initializeBlock(() => <HelloWorldApp />);
Any ideas here? This is my first time setting up a node.js development environment