0

Having this set up using superagent

this.acceptContentType = "application/json";

req = Request.post(absoluteUrl)
 .timeout(config.runtime.apiTimeoutMs)
 .set('Accept', this.acceptContentType);

req.attach('files', file, file.name);

When running this, im getting an error stating .on is not a function. Did some research, and it seems to be related to the FormData() object. For some reason superagent exposes node-internals to my client. This worked fine using Webpack, but after porting to Parcel, this is broken. Any pointers would be appreciated.

thsorens
  • 1,308
  • 12
  • 21

1 Answers1

0

According to the documentation for Superagent, Webpack and Browserify "knows" to fetch the client-version. Parcel picked the Node-implementation. To force this, i changed:

import Request from 'superagent';

to

import Request from 'superagent/lib/client';

That seems to fix the issue.

thsorens
  • 1,308
  • 12
  • 21