Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

API Error in React with axios

Solved
Jump to Solution
1366 4
cancel
Showing results for 
Search instead for 
Did you mean: 

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); });

Spoiler
GET https://api.airtable.com/v0/undefined/Settings/recKrP4fJsCmnavbd? 404
AirtableError {error: 'NOT_FOUND', message: 'Could not find what you are looking for', statusCode: 404}






1 Solution

Accepted Solutions

"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.

See Solution in Thread

4 Replies 4

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.

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.

"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.

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.