forwardemail / forwardemail/superagent

Null fields not included in FormData, unlike jQuery

Open
#963 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

I'm making POST requests like this:

```
request.post(uri)
.set('Content-Type', 'application/x-www-form-urlencoded')
.send({myFlag: 'dunce'})
.end((err, result) => { ....
```

That works fine, and the FormData includes `myFlag` as you'd expect. But if I instead send `{myFlag: null}` then the FormData contains no reference at all to `myFlag`. Previously I was using `jQuery.ajax`, and in that case the FormData would still contain a reference to `myFlag`, but obviously with an empty value. SuperAgent breaks my server calls, which insist on seeing `myFlag`.

Since this behavior is inconsistent with jQuery, I'm wondering whether there's an option to align them, or is one of jQuery or SuperAgent doing this incorrectly?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.