Skip to content

feat(http): accept string for method in RequestOptions class and interface #2840

@jeffbcross

Description

@jeffbcross

Currently, the method must be of the ResponseMethods TypeScript enum, which is really an integer. So to create a request in TypeScript, one would use the enum to describe the method instead of passing in the method string:

var options = new RequestOptions({
  url: '/foo.json',
  method: RequestMethods.POST
});
var request = new Request(options);

This adds some convenience for TypeScript and Dart users to get some IDE/compiler help to make sure the method is a valid value. But plain old ES5 users probably don't want to pass 0 as the method value. Instead, RequestOptions should have the method property be a union type of RequestMethods | string, and should validate the provided string & throw if not a recognized method.

I'm not sure Request class needs to accept method as a string though. Ideally, we could reduce instances of type ambiguity to public APIs.

Metadata

Metadata

Assignees

Labels

effort1: hoursfeatureLabel used to distinguish feature request from other issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions