Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
use body for POST,PUT,DELETE (not just POST) (see #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott J. Miles committed Apr 28, 2014
1 parent ddecf45 commit 23500e1
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions core-ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
@status beta
@homepage github.io
-->

<link rel="import" href="core-xhr.html">

<polymer-element name="core-ajax" attributes="url handleAs auto params response method headers body contentType withCredentials">

<script>

Polymer('core-ajax', {
Expand Down Expand Up @@ -280,8 +277,8 @@
*/
go: function() {
var args = this.xhrArgs || {};
// TODO(sjmiles): alternatively, we could force POST if body is set
if (this.method === 'POST') {
// TODO(sjmiles): we may want to default to POST if body is set
if (this.bodyMethods[this.method.toUpperCase()]) {
args.body = this.body || args.body;
}
args.params = this.params || args.params;
Expand All @@ -299,16 +296,20 @@
this.handleAs === 'document') {
args.responseType = this.handleAs;
}

args.withCredentials = this.withCredentials;
args.callback = this.receive.bind(this);
args.url = this.url;
args.method = this.method;
return args.url && this.xhr.request(args);
}
},

bodyMethods: {
POST: 1,
PUT: 1,
DELETE: 1
}

});

</script>

</polymer-element>

0 comments on commit 23500e1

Please sign in to comment.