cloudconvert API 不使用 netlify 无服务器功能

cloudconvert API NOT working with netlify Serverless function

我使用的是来自 node JS 的 cloudconvert api,当我在 heroku 中托管时它运行良好。但是当我制作 netlify 无服务器函数时,它返回错误。是因为serverless function没有完成任务就退出了?

try {
    let job = await cloudConvert.jobs.create({
      tasks: {
        'const-1': {
          operation: 'const/raw',
          // file: file_string_output,
          file: '<div>Welcome ... testing...</div>',
          filename: `${fileName}.html`,
        },
        'task-1': {
          operation: 'convert',
          input_format: 'html',
          output_format: 'pdf',
          engine: 'chrome',
          input: ['const-1'],
          zoom: 1,
          print_background: true,
          display_header_footer: false,
          wait_until: 'load',
          wait_time: 0,
        },
        'export-1': {
          operation: 'export/s3',
          input: ['task-1'],
          bucket: process.env.S3_BUCKET_NAME,
          region: process.env.S3_BUCKET_REGION,
          access_key_id: process.env.S3_ACCESS_KEY,
          secret_access_key: process.env.S3_ACCESS_SECRETE,
          key: `${process.env.S3_BUCKET_FOLDER}/${fileName}.pdf`,
        },
      },
    })

    cloudConvert.jobs.subscribeEvent(job.id, 'finished', (event) => {
      console.log('cloud convert stages finished', event.job)
    })

    cloudConvert.jobs.subscribeEvent(job.id, 'error', (event) => {
      console.log('error', event.job)
    })

    cloudConvert.jobs.subscribeTaskEvent(job.id, 'finished', async (event) => {
      console.log('cloud convert Task stages finished', event.job)

      
    })

    cloudConvert.jobs.subscribeTaskEvent(job.id, 'error', (event) => {
      console.log('Task on error', event.task)
    })
  } catch (error) {
    console.log(' Cloud convert key is invalid??:', error)
  } 

我找到问题了。在下面的代码中,有一个错字。 运算:'const/raw',==>>>> 运算:'import/raw'

是我的错。由于 netlify serverless 不支持 Es6,我必须将所有导入语法更改为 require() 语法,并且我进行了全局搜索并替换了 import==> const ,这也影响了这里。太傻了我...

'const-1': {
          operation: 'const/raw',   ==>>>>
          // file: file_string_output,
          file: '<div>Welcome ... testing...</div>',
          filename: `${fileName}.html`,
        },