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
Doesn't send body in PUT request #165
Comments
@wzup Check out #97 (comment) to see if it's related to your issue. I've never used this plugin personally and don't have time to dig in right now so it's hard for me to say for sure. |
Both methods do not work, I also found that the plugin doesn't set headers. I set:
I receive:
And on top of that, I get this when I run tests. Any test, every time:
Just LOL. This plugin creates more issues than it solves. |
chai-http is built on top of the superagent library. I believe the |
Here are approaches that work. The
Many thanks to @barraponto. There is his answer here #97 (comment).
In both cases To authors. |
More here
|
Just as a side note, I found that the reason my body parameters was empty was because I had called the appropriate middleware functions in the wrong order in the node.js express server. For example, this left the body empty var express = require('express');
var app = express();
var routesApi = require('./routes/routes');
var bodyParser = require('body-parser');
app.use('/api', routesApi);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json()); And this filled the body parameters the correct way var express = require('express');
var app = express();
var routesApi = require('./routes/routes');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use('/api', routesApi); |
@curtis-n I'd usually recommend against setting both json and urlencoded body parsers globally. The performance hit is minimal for running both by default, but I'd rather have my route defined as |
@wzup
And then your route will receive the See SO answer: https://stackoverflow.com/questions/39470566/request-body-undefined-in-supertest |
This work to me... TY @curtisnn |
No
body
inreq.body
. Neither of both setsreq.body
:field
andsend
.Why? What's wrong?
Set up:
And
req.body
is an empty objectThe text was updated successfully, but these errors were encountered: