Cron jobs on NextJS

1062 0
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

Hi, I would like to know how to create a cron job with NextJS and Vercel. I tried it like I did with another API but with Airtable it fails to compile. This is the error : 

Failed to compile.

Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More:

Import trace for requested module:

> Build failed because of webpack errors

Here is the code that creates the error :

export const config = {
  runtime: "edge",
var base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY }).base(

const table = base("Orders");

export default async (req: NextRequest) => {
  // To set two dates to two variables
  var date1 = new Date();

  // To calculate the time difference of two dates
  var Difference_In_Date = date1.getDate() - 74;
  return await table
    .select({ filterByFormula: `(SEARCH('${date1.getFullYear()+"-"+date1.getMonth()+"-"+date1.getDate()}',{Order Date}))` })
    // .select({
    //   maxRecords: 1,
    //   filterByFormula: `SEARCH("12293781",{Order_Unique Number})`,
    // })
    .all(function page(objs) {
      objs.forEach(function (obj:any) {
        let firstName = obj.get("Customer_First Name");
        let email = obj.get("Customer_Email");
        if (obj.get("Order_Collected") == true) {

Thank you for the answer in advance!

0 Replies 0