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

Limit the request method type #917

Closed
wants to merge 1 commit into from
Closed

Limit the request method type #917

wants to merge 1 commit into from

Conversation

ofirgeller
Copy link

breaking change: Before this change the uppercase form of each method works as well as the lowercase. This change will cause typescript compiler errors for users that chose to use the upper case form.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.5%) to 93.719% when pulling f6f1c28 on ofirgeller:patch-1 into f31317a on mzabriskie:master.

@rubennorte
Copy link
Member

Thanks for the PR but I think it's a better idea to accept both (uppercase and lowercase). #912 is in progress for it.

@rubennorte rubennorte closed this May 28, 2017
@ofirgeller
Copy link
Author

@rubennorte

That can be done simply by changing the code to
method?: 'get'|'delete'|'head'|'post'|'put'|'patch'|'GET'|'DELETE'|'HEAD'|'POST'|'PUT'|'PATCH';

That would still be an improvement for the user (no errors due to misspelling).

I do think that it would be less nice for auto complete and I personally don't like to create two ways of doing the same thing but sure. ¯_(ツ)_/¯

@rubennorte
Copy link
Member

@ofirgeller I see the point, but there's also the fact that we don't currently limit the allowed request methods. In this case, you're missing OPTIONS, CONNECT and TRACE from the spec.

@nickuraltsev you know TS better than I do. WDYT?

@nickuraltsev
Copy link
Member

I don't believe we should limit the allowed request methods. If someone wants to use a non-standard HTTP method like PURGE, axios should let them do that.

@ofirgeller
Copy link
Author

@nickuraltsev

I see your point, but this is an edge case and the user can always cast to any to get around the type.

config.method = 'PURGE' as any;

Also If it's not an edge case because a none standard method is common in the real world we can include it in the type.

@axios axios locked and limited conversation to collaborators May 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants