question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible inconsistent method: parse

See original GitHub issue

I’ve run into some trouble while trying to customize the way response bodies are parsed – specifically on the client.

From these tests, it appears that the parse method of the node library is used to customize how response bodies are parsed.

This test shows that the parse method of the client library is used to customize how request bodies are serialized.

Is this inconsistency intentional? If not and a maintainer would like to specify the intended behavior, I’d be happy to open a PR.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kornelskicommented, Mar 16, 2016

The term serialize is used in Superagent’s codebase, so for 2.0 I suggest:

  • parse(fn) for parsing response body only (this is a breaking change)
  • serialize(fn) for generating data to send in the request
0reactions
focusauruscommented, Jan 3, 2016

Sadly, it looks like request.parse indeed sets a request body serializer and then this._parse in the browser request instance is indeed a function used for serializing request bodies. Thus I don’t think the confusion is request vs. response but rather parse vs. serialize. I’d like to see a PR for the following changes:

  • rename the private var this._parser to something more clear like this._serializeBody in the browser client code
  • Add a new clear public API to set the request body serializer. Perhaps req.serializeBody() (open to more concise suggestions for the name). This can be an alias of the current req.parse in the client code.
  • I don’t see any functionality in the node code to provide a custom body serializer. It seems to all just be hard coded in exports.serialize which presumably can be overridden in a straightforward way if a user has read the source, but maybe we should make an explicit API to keep parity with the browser code.
  • deprecate existing request.parse with corresponding doc updates
Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent parsing using find method in Beautiful Soup
I am attempting to parse a website with the find() method, but it doesn't find all of the elements I attempting to parse....
Read more >
parse method signature is inconsistent with react-docgen · Issue ...
I noticed this while doing a clause like below: const reactDocgen = require('react-docgen') const tsDocgen = require('@bebraw/react-docgen-typescript').
Read more >
ACT seems to be inconsistent with its parsing; any ... - Reddit
My ACT seems to parse people very low sometimes, when I feel like they're actually doing better/give me their own parse numbers. Any...
Read more >
Parsing error [bug?] with systems of nonlinear PDEs ...
NDSolveValue::femper: PDE parsing error of Div[{{1,0},{0,v}}.Grad$9730]. Inconsistent equation dimensions. It seems like extremely basic ...
Read more >
[Rd] Inconsistent Parse Behavior
Under some specific conditions, `parse` seems to produce inconsistent and potentially incorrect results the first time it is run in a fresh clean...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found