Mine was a text input and I'm adding this answer here regardless so it would help people. Make sure your encoding is set when parsing! I struggled to make it work until I set a proper value to it.
This was the error I was getting without using any parser:
error info: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.
Received an instance of undefined at Function.from (buffer.js:327:9)
We do not have to use body-parser now in Express as others have already mentioned, but just that app.use(express.text());
did not solve my issue.
undefined now changed to Object. According to Express documentation, request body returns an empty object ({}) if Content-Type
doesn't match (among others).
error info: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.
Received an instance of Object at Function.from (buffer.js:327:9)
The encoding type you set needs to be on point as well. In my case, it was text/plain. You can change it to suit your needs like JSON, etc. I did this and voila! Worked like a charm!
app.use(express.text({
type: "text/plain"
}));