Skip to content

Commit f80e147

Browse files
committed
Require form-data on-demand, so that it doesn’t throw when not in use
Fixes #933
1 parent 8180a19 commit f80e147

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/request-base.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*/
44
var isObject = require('./is-object');
55

6-
var FormData = require('form-data'); // browserify compatible
7-
86
/**
97
* Clear previous timeout.
108
*
@@ -163,7 +161,10 @@ exports.unset = function(field){
163161
* @api public
164162
*/
165163
exports.field = function(name, val) {
166-
if (!this._formData) this._formData = new FormData();
164+
if (!this._formData) {
165+
var FormData = require('form-data'); // browserify compatible. May throw if FormData is not supported natively.
166+
this._formData = new FormData();
167+
}
167168
this._formData.append(name, val);
168169
return this;
169170
};

0 commit comments

Comments
 (0)