Permalink
Browse files

Warn when using unsupported mix of send and field (#1153)

  • Loading branch information...
1 parent d7d2839 commit 23ca7c1b9f875db31751b3c38cf2556514b64dc4 @pornel pornel committed with focusaurus Jan 11, 2017
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/request-base.js
View
@@ -288,6 +288,10 @@ RequestBase.prototype.field = function(name, val) {
throw new Error('.field(name, val) name can not be empty');
}
+ if (this._data) {
+ console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");
+ }
+
if (isObject(name)) {
for (var key in name) {
this.field(key, name[key]);
@@ -424,6 +428,10 @@ RequestBase.prototype.send = function(data){
var isObj = isObject(data);
var type = this._header['content-type'];
+ if (this._formData) {
+ console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");
+ }
+
if (isObj && !this._data) {
if (Array.isArray(data)) {
this._data = [];

0 comments on commit 23ca7c1

Please sign in to comment.