Skip to content

Change default as in parse middleware #34

Open
@agilgur5

Description

@agilgur5

Currently the default property for as is body, but the logic makes this undesirables, as:

https://github.com/mjackson/http-client/blob/master/modules/index.js#L205

    if (as in response)
      return response[as]

will by default return response.body, which may already be populated.

I run a response middleware after the parse usually, but using
parse('json'), recv(({body}) => body)
results in undefined to be output.

If I instead use
parse('json', 'jsonData'), recv(({jsonData}) => jsonData),
it works as intended, returning the JSON/JS Object.

Not sure what a better name would be; perhaps bodyData sticking by previous conventions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions