forwardemail / forwardemail/superagent
Smileys and Emojis are not sent in correct format in POST request
- Dominant language
- JavaScript
- Stars
- 16.6k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I have a simple text field in which I allow text or emojis/smileys to be added and then when the user clicks "Send" button, I send the request via SuperAgent to my backend controller.
When I debug my backend controller values, the values I see are garbage values and not the ones that are coming from the UI.
This happens only with Smileys and Emoji characters. The plain text appears correct.
Note that this issue persist only when using superagent. When I use the $.post() approach of sending ajax request, I get the data in correct format in my backend.
Example code which is NOT working:
```
request.set('Content-Type', 'application/x-www-form-urlencoded')
.set('deviceType', 'browser')
.send({ userId: userId })
.send({ text: text }) // THIS TEXT CONTAINS PLAIN TEXT AND SMILEYS/EMOJIS
.then(res => {
if (res.statusCode == 200) {
if (actionType == "reply") {
alert("Reply added successfully","info",true);
} else if (actionType == "reply-edit") {
alert("Reply added successfully","info",true);
} else {
alert("Comment added successfully","info",true);
}
} else {
alert("An unexpected error occured while processing your request. Please try again later.", "error",false);
}
}).catch(err => {
console.log("Error: "+err);
alert("An unexpected error occured while processing your request. Please try again later.", "error",false);
});
```
Contributor guide
Research direction
Start by reproducing the supplied SuperAgent request using request.set('Content-Type', 'application/x-www-form-urlencoded') and the chained .send calls, then compare its payload with the working $.post() approach. Confirm the backend receives plain text and emoji characters correctly; the issue does not mention a repository file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100