0

每当我将项目的本地 URL 设为http://127.0.0.1:3000/获取方法时,我都会收到如下错误:

2018/08/07 15:19:41 Invoking index.handler (nodejs4.3)
2018/08/07 15:19:42 Mounting /e/serverless/sanlamFundRisk as /var/task:ro inside runtime container
←[32mSTART RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381 Version: $LATEST←[0m
←[31mUnable to import module 'index': Error←[0m
←[31m    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)←[0m
←[32mEND RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381←[0m
←[32mREPORT RequestId: b4539898-148e-174b-a4f8-fdfccaaa4381     Duration: 17.25 ms      Billed Duration: 100 ms Memory Size: 128 MB     Max Memory Used: 23 MB     ←[0m

2018/08/07 15:19:48 ←[31mFunction returned an invalid response (must include one of: body, headers or statusCode in the response object): %!s(<nil>)
←[0m
4

1 回答 1

0

将 API Gateway 与 Lambda 代理集成一起使用时,Lambda 函数需要返回具有特定格式的响应

例子:

  return {
    "isBase64Encoded": false,
    "statusCode": 200,
    "headers": {
      'Content-Type:': 'application/json'
    },
    "body": JSON.stringify({
        "example": "hello"
    })
  }
于 2018-08-07T11:00:58.277 回答