Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: can't load the form-data polyfill in browsers because fs doesn't exist #184

Merged
merged 1 commit into from
Oct 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
var debug = require('debug')('httpsnippet')
var es = require('event-stream')
var MultiPartForm = require('form-data')
var FormDataPolyfill = require('form-data/lib/form_data')
var qs = require('querystring')
var reducer = require('./helpers/reducer')
var targets = require('./targets')
Expand Down Expand Up @@ -128,7 +127,7 @@ HTTPSnippet.prototype.prepare = function (request) {
// This hack is pretty awful but it's the only way we can use this library in the browser as if we code this
// against just the native FormData object, we can't polyfill that back into Node because Blob and File objects,
// which something like `formdata-polyfill` requires, don't exist there.
const isNativeFormData = !(form instanceof FormDataPolyfill)
const isNativeFormData = (typeof form[Symbol.iterator] === 'function')

// easter egg
const boundary = '---011000010111000001101001'
Expand Down