You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
An example of a netlify function using your library would be welcome. Not sure why but I always end up with an error saying that "SyntaxError: Cannot use import statement outside a module"
And this happens wether I use the require or import syntax...
Here is an example code:
// import { AsyncAirtable } from 'asyncairtable';constAsyncAirtable=require('asyncairtable');constkeys={atApiKey: process.env.AT_API_KEY,atDb: process.env.AT_DB,}constasyncAirtable=newAsyncAirtable(keys.atApiKey,keys.atDb);asyncfunctiongetMoviesWithRelatedAsyncAirtable(){constmovies=awaitasyncAirtable.select('Movies')constformattedMovies=formatData(movies);formattedMovies.forEach(async(movie)=>{movie.DirectorFull=awaitgetDirector(movie.Director[0]);if(movie&&movie.Actors){movie.ActorsFull=awaitgetActors(movie.Actors);}})returnformattedMovies;}asyncfunctiongetDirector(directorId){constdirector=awaitasyncAirtable.find('Directors',directorId)returndirector.fields;}functiongetActors(actorsIds){constactors=[]actorsIds.forEach(async(actorId)=>{constactor=awaitasyncAirtable.find('Actors',actorId)actors.push(actor.fields)})returnactors;}functionformatData(data){returndata.map(item=>({id: item.id,
...item.fields}))}// The actual netlify function !exports.handler=async(event,context)=>{try{constmovies=awaitgetMoviesWithRelatedAsyncAirtable();return{statusCode: 200,body: JSON.stringify(movies),};}catch(err){console.log(err);return{statusCode: 500,body: JSON.stringify(err),};}}
The text was updated successfully, but these errors were encountered:
Request from ::1: GET /.netlify/functions/movies2
Error: Error: Error: TypeError: fetch_default is not a function
at AsyncAirtable.<anonymous> (/Users/f/Sites/sister/node_modules/asyncairtable/src/asyncAirtable.ts:157:13)
at Generator.throw (<anonymous>)
at rejected (/Users/f/Sites/sister/.netlify/functions-serve/movies2/src/functions/movies2/movies2.js:3388:32)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
An example of a netlify function using your library would be welcome. Not sure why but I always end up with an error saying that "SyntaxError: Cannot use import statement outside a module"
And this happens wether I use the require or import syntax...
Here is an example code:
The text was updated successfully, but these errors were encountered: