Skip to content
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

I can't get req.body #381

Closed
NSLog0 opened this issue Sep 1, 2016 · 6 comments
Closed

I can't get req.body #381

NSLog0 opened this issue Sep 1, 2016 · 6 comments

Comments

@NSLog0
Copy link

NSLog0 commented Sep 1, 2016

Hi, I use multer to upload file and I want to attach other parameter in request In postman like this

screen shot 2559-09-01 at 17 35 45

my code
screen shot 2559-09-01 at 17 34 39

So I can't get req.body.test_body , How do I fix this??

@LinusU
Copy link
Member

LinusU commented Sep 3, 2016

I don't see req.body.test_body referred to anywhere in your code? How is it not working?

also, please post the code using fenced code blocks, that way others can copy and search the code. Like so:

```js
Write code here
```

@NSLog0
Copy link
Author

NSLog0 commented Sep 4, 2016

I just use

 console.log(req.body);

So I see is {}

@LinusU
Copy link
Member

LinusU commented Sep 4, 2016

Your code screenshot doesn't show how it's all called so this is impossible for me to debug. Could you provide a minimum erring test case?

@iyunusov
Copy link

if your file input element is in the top of form then every data below that gets assigned to req.body after your image is uploaded, in the result of which body remains empty while you upload photo.. So take file input element to very bottom of your form so that req.body will have data from other input elements

@bliteknight
Copy link

What solved it for me was making sure the "Content-Type" header information in postman was not set; it had been set to "application/x-www-form-urlencoded" and removing allowed me to receive the file on my backend server as well as the req.body values.

@NSLog0
Copy link
Author

NSLog0 commented Jan 11, 2018

I have solved and I will close this issues. sorry for last reply

@NSLog0 NSLog0 closed this as completed Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants