Skip to main content
Solved

API Error in React with axios


Forum|alt.badge.img+3

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

Show content

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}







Best answer by Justin_Barrett

Antonina wrote:

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.

View original
Did this topic help you find an answer to your question?

4 replies

Justin_Barrett
Forum|alt.badge.img+20

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.


Forum|alt.badge.img+3
  • Author
  • New Participant
  • 2 replies
  • December 6, 2022
Justin_Barrett wrote:

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.


Justin_Barrett
Forum|alt.badge.img+20
  • Inspiring
  • 4647 replies
  • Answer
  • December 7, 2022
Antonina wrote:

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.


Forum|alt.badge.img+3
  • Author
  • New Participant
  • 2 replies
  • December 8, 2022
Justin_Barrett wrote:

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


Reply