Javascript 在AWS lambda上处理事件返回

Javascript 在AWS lambda上处理事件返回,javascript,amazon-web-services,api,aws-lambda,Javascript,Amazon Web Services,Api,Aws Lambda,我目前正在使用lambda发送API详细信息以获取访问令牌。然后我想保存该访问令牌以供以后使用。似乎它没有保存访问密钥。有什么建议吗? 拉姆达: 这是我的错误报告: Response { "errorType": "TypeError", "errorMessage": "Cannot read property 'data' of undefined", "t

我目前正在使用lambda发送API详细信息以获取访问令牌。然后我想保存该访问令牌以供以后使用。似乎它没有保存访问密钥。有什么建议吗? 拉姆达:

这是我的错误报告:

 Response
    {
      "errorType": "TypeError",
      "errorMessage": "Cannot read property 'data' of undefined",
      "trace": [
        "TypeError: Cannot read property 'data' of undefined",
        "    at Runtime.exports.handler (/var/task/index.js:26:48)",
        "    at processTicksAndRejections (internal/process/task_queues.js:93:5)"
      ]
    }
这是我的日志:

    Function Logs
    gOutput],
        agent: Agent {
          _events: [Object: null prototype],
          _eventsCount: 2,
          _maxListeners: undefined,
          defaultPort: 443,
          protocol: 'https:',
          options: [Object],
          requests: {},
          sockets: [Object],
          freeSockets: {},
          keepAliveMsecs: 1000,
          keepAlive: false,
          maxSockets: Infinity,
          maxFreeSockets: 256,
          scheduling: 'fifo',
          maxTotalSockets: Infinity,
          totalSocketCount: 1,
          maxCachedSessions: 100,
          _sessionCache: [Object],
          [Symbol(kCapture)]: false
        },
        socketPath: undefined,
        method: 'POST',
        maxHeaderSize: undefined,
        insecureHTTPParser: undefined,
        path: 'API/connect/token',
        _ended: true,
        res: IncomingMessage {
          _readableState: [ReadableState],
          _events: [Object: null prototype],
          _eventsCount: 3,
          _maxListeners: undefined,
          socket: [TLSSocket],
          httpVersionMajor: 1,
          httpVersionMinor: 1,
          httpVersion: '1.1',
          complete: true,
          headers: [Object],
          rawHeaders: [Array],
          trailers: {},
          rawTrailers: [],
          aborted: false,
          upgrade: false,
          url: '',
          method: null,
          statusCode: 200,
          statusMessage: 'OK',
          client: [TLSSocket],
          _consuming: false,
          _dumped: false,
          req: [Circular *1],
          responseUrl: 'myendpoint',
          redirects: [],
          [Symbol(kCapture)]: false,
          [Symbol(RequestTimeout)]: undefined
        },
        aborted: false,
        timeoutCb: null,
        upgradeOrConnect: false,
        parser: null,
        maxHeadersCount: null,
        reusedSocket: false,
        host: 'myhost',
        protocol: 'https:',
        _redirectable: Writable {
          _writableState: [WritableState],
          _events: [Object: null prototype],
          _eventsCount: 2,
          _maxListeners: undefined,
          _options: [Object],
          _ended: true,
          _ending: true,
          _redirectCount: 0,
          _redirects: [],
          _requestBodyLength: 81,
          _requestBodyBuffers: [],
          _onNativeResponse: [Function (anonymous)],
          _currentRequest: [Circular *1],
          _currentUrl: 'myendpoint',
          [Symbol(kCapture)]: false
        },
        [Symbol(kCapture)]: false,
        [Symbol(kNeedDrain)]: false,
        [Symbol(corked)]: 0,
        [Symbol(kOutHeaders)]: [Object: null prototype] {
          accept: [Array],
          'content-type': [Array],
          'user-agent': [Array],
          'content-length': [Array],
          host: [Array]
        }
      },
      data: {
        access_token: 'ThisIsMyAccessKeyIGetBackAndWantToSave',
        expires_in: 3600,
        token_type: 'Bearer'
      }
    }
    2021-04-10T10:41:22.858Z    e5e3bc3a-f08d-4077-8897-709225abd5f8    ERROR   Invoke Error    {"errorType":"TypeError","errorMessage":"Cannot read property 'data' of undefined","stack":["TypeError: Cannot read property 'data' of undefined","    at Runtime.exports.handler (/var/task/index.js:26:48)","    at processTicksAndRejections (internal/process/task_queues.js:93:5)"]}
    END RequestId: e5e3bc3a-f08d-4077-8897-709225abd5f8
    REPORT RequestId: e5e3bc3a-f08d-4077-8897-709225abd5f8  Duration: 1631.22 ms    Billed Duration: 1632 ms    Memory Size: 128 MB Max Memory Used: 19 MB
    
    Request ID
    e5e3bc3a-f08d-4077-8897-709225abd5f8

我正在做的是将客户端详细信息发送到此端点,它将返回一个在特定时间段内有效的访问密钥。它确实返回了一个不需要的大量实体,我只需要将信息保存在数据中:但它不断地向我提供所提到的错误,即使我得到了正确的响应。

谢谢,似乎我所要做的就是正确定义我的密钥

var mykey = postData.data.accesskey

postData.response.data
应该是
postData.data
var mykey = postData.data.accesskey