0

I have developed an AWS lambda function and I am testing it locally on my machine. To run the function locally, I use the following template.yml.

If I log short strings, then the logging works without problems. However, if I want to log longer JS objects, only a small snippet is displayed and not the full object. How can I display the whole object?

template.yml

Resources:
  Function:
    Type: AWS::Serverless::Function
    Properties:
      Timeout: 900
      MemorySize: 128
      Handler: index.handler
      CodeUri: /.../
      Runtime: nodejs16.x
      Architectures:
        - x86_64
      Environment:
        Variables:
    Metadata:
      SamResourceId: Function
const response = await axios.get(url);
console.log('test');
console.log(`${JSON.stringify(response)}`);

Logging response:

2023-07-29T11:50:02.629Z 8f7e4a8a-acad-4da9-ab7f-bca86e7a013a LOG test

--- property '_httpMessage' closes the circle

laprof
  • 1,246
  • 3
  • 14
  • 27

1 Answers1

1

It's because you have circular references in the Axios response. Either use an npm module for this, check out suggestions such as this or better yet just print the relevant data such as the data and status field:

console.log(JSON.stringify({ data: response.data, status: response.status }))
cyberwombat
  • 38,105
  • 35
  • 175
  • 251