post(url, data) does not send any data
See original GitHub issuesuperagent allows the following syntax:
request(app).post('/url', { foo: 'bar' })
This should set the content-type to json and send the JSON data in the request body.
With supertest the above syntax results in no content-type and no body.
testcase:
it('.post should work with data', function (done) {
var app = express();
app.use(express.bodyParser());
app.post('/', function(req, res){
res.send(req.body.name);
});
request(app)
.post('/', { name: 'tobi' })
.expect('tobi', done);
})
Thanks.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:18
- Comments:20 (1 by maintainers)
Top Results From Across the Web
JavaScript - POST to URL not sending data - Stack Overflow
I'm trying to send POST data from a Chrome extension to a website controlled by me. However, when sending the POST data I...
Read more >POST requests don't send any data · Issue #831 - GitHub
I can't send any data with POST. I'm on Normal mode, raw, JSON, with the data {"hello": "world"}. My server is receiving empty...
Read more >Building requests | Postman Learning Center
You can send requests in Postman to connect to APIs you are working with. Your requests can retrieve, add, delete, and update data....
Read more >Sending form data - Learn web development | MDN
The data is appended to the URL as a series of name/value pairs. After the URL web address has ended, we include a...
Read more >HTTP Methods GET vs POST - W3Schools
GET is used to request data from a specified resource. Note that the query string (name/value pairs) is sent in the URL of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding
.type('form')
fixed this for me.This worked for me