Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let superagent handle request body #57

Merged
merged 3 commits into from
Apr 11, 2017

Conversation

acontreras89
Copy link
Contributor

See #55 for motivation and discussion.

@acontreras89
Copy link
Contributor Author

acontreras89 commented Apr 1, 2017

I've pushed a new commit cleaning up the adapter (and tests) a bit. Let me know if you want me to roll it back.

This commit also added an assertion missing in one of the tests, as well as support for HEAD requests (constant was defined but not handled in the switch statement.) You might want to preserve these.


if (body) {
request.send(body);
if (!(method in httpMethods)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think of it, this is completely wrong as it is checking against the names of the constants, rather than their values. It works because they're the same.

Copy link
Contributor

@ryanashcraft ryanashcraft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@acontreras89 Talking with the team we decided that this is a reasonable change to make. Thanks for putting in the work for the proof of concept.

I just have one request. Once that change gets in and the tests pass I'd like to merge this.

@@ -1,30 +1,13 @@
import superagent from 'superagent';
import * as httpMethods from '../constants/http-methods';

export const createRequest = (url, method) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you keep this function and the switch statement for explicitness?

in addition, we can move to making this function not exported with your change in tests/. that would be great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍 let me know if you need anything else

@ryanashcraft
Copy link
Contributor

Also – heads up. I plan to merge #60 soon which might cause some disruption. Sorry for any inconvenience.

@acontreras89
Copy link
Contributor Author

What about this

This commit also added [...] support for HEAD requests

@ryanashcraft ryanashcraft merged commit 3f8d670 into amplitude:master Apr 11, 2017
@ryanashcraft
Copy link
Contributor

Looks great. I'm ok with adding HEAD method support too. Thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants