Dec 06, 2022 02:37 AM
Hello!
I am getting error while requesting api - using your javascript example
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'YOUR_API_KEY'}).base('XXXXXXXXXXXXXXX');
base('Settings').find('recKrP4fJsCmnavbd', function(err, record) {
if (err) { console.error(err); return; }
console.log('Retrieved', record.id); });
Solved! Go to Solution.
Dec 07, 2022 01:31 PM
"the very beginning" meaning the first line of the code that you posted? If so, that's likely an indicator that the environment where the React code is running isn't on a Node.js server. The require() function will only work when running the script on a Node.js server. On top of that, you would need to install the "airtable.js" module onto the server from the link provided in the API docs.
Dec 06, 2022 04:19 AM
Could you please share more details about where and how you're trying to use this code? The code itself isn't providing any clues as to the source of the problem.
Dec 06, 2022 09:11 AM
I got the code from the Airtalbe Help API.
I want to use this code on a React website in order to read the data.
I have a problem from the very beginning - the API returns an error.
Dec 07, 2022 01:31 PM
"the very beginning" meaning the first line of the code that you posted? If so, that's likely an indicator that the environment where the React code is running isn't on a Node.js server. The require() function will only work when running the script on a Node.js server. On top of that, you would need to install the "airtable.js" module onto the server from the link provided in the API docs.
Dec 07, 2022 04:18 PM
Thank you, Justin.
Today I found confirmation of your remark in the video on YouTube - but I did not have time to check it. I think everything will work fine now.