-
-
Notifications
You must be signed in to change notification settings - Fork 57
Description
I'm submitting a feature request
- Library Version:
aurelia-http-client 1.0.4
Please tell us about your environment:
-
Operating System:
macOS Sierra 10.12.3 -
Node Version:
7.3.0 -
NPM Version:
3.10.10 -
JSPM OR Webpack AND Version
JSPM 0.16.52 -
Browser:
all (browser-agnostic) -
Language:
ESNext -
What is the motivation / use case for changing the behavior?
The fluent API for building HTTP requests is fantastic, but I would like to suggest an enhancement:.withForm()and.withFormData().
I realize that we can simply create a FormData object, according to the xhr2 spec, and then submit that using HttpClient::post(). But it would be both convenient and semantic to do this:
.withForm(formElement, formDataObject?)
or
.withFormData(formDataObject)
and then have that translated by http-client into a FormData instance behind the scenes. The former addresses those instances where the form data is built up from a an HTML form (with the optional ability to append additional data, according to the spec); and the latter addresses those instances where no HTML form is involved at all.
As it stands now, from looking at http-client, there's nothing connecting the application/x-www-form-urlencoded content type to the API semantically. One might wrestle for quite a while, as I did, with .withParams() and .withContent() to try to effect such a request, but with no success.
Just a suggestion...