Skip to content

Why is data.body stringified on request events? #24

@tobiasbueschel

Description

@tobiasbueschel

Thanks for all the work with this library. It's really useful :-)

One thing I have noticed is that on request events, data.body is stringified as seen here:

if (this.body) {
  data.body = this.body.toString('utf8')
}

[index.js, line: 36]

Just curious why this is done?

I have a particular use case where I want to log all outgoing requests and responses but need to obfuscate sensitive information such as passwords, tokens etc. from the log messages. Previously, my Bunyan serializer was just able to go through any body object and remove sensitive values from any keys that I declared sensitive. But as the data.body is not what it originally was when sending the request, I would have to JSON.parse(data.body) it again.

Thanks :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions