-
Notifications
You must be signed in to change notification settings - Fork 759
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
post(url, data) does not send any data #189
Comments
+1 |
use:
|
Adding |
+1 Mikker. |
Thanks a lot, mayby fix the Accept POST Header testServer
.post('/api/book/save/')
.type('form')
.send(data.book)
.set('Accept', /application\/json/)
.expect(201)
.end(function (err, res) { done(); }); |
Can we attach image file along with the same request without changing type('form' |
This worked for me
|
+1 Montaro |
1 similar comment
+1 Montaro |
Seems the readme has only this example, which can be very confusing. request(app)
.post('/')
.field('name', 'my awesome avatar')
.attach('avatar', 'test/fixtures/homeboy.jpg') I didn't know there is another method: request(app)
.post('/api/book/save/')
.type('form')
.send(data.book)
.set('Accept', /application\/json/)
.expect(201)
.end(function (err, res) { done(); }); It's weird that nested form data breaks in |
+1 |
@fritx @zanemcca I don`t know how relevant is to see the help from this library for the supertest. But you can try using the documentation from it. |
Adding .type('form') fixed my problem too |
adding these two lines solves this problem |
Be sure you're not looking for |
it should use form as the default type instead of json. |
I'm having trouble with a basic |
@samueljseay as a heads up expressjs version 4 and above does not include body parsing middleware. See the migration guide. You must use a separate middleware library like body-parser. |
Nowadays, you should use |
I want send multipart/form-data and `test('multipart/form-data', async (done) => { app.use(express.json()); app.post('/', (req, res) => {
}); await request(app) supertest=6.1.3 |
superagent allows the following syntax:
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:
Thanks.
The text was updated successfully, but these errors were encountered: