Issue
I want to upload an image from android device to node server. Currently I am converting the image to Base64 string and passing it using AsyncTask. I don't understand what's happening on the server side. It displays 'undefined' when I log the request body to the console.
This is the android code for converting image to Base64 string and uploading to node server:
This is the console output after receiving the image data:
This is the server code:
What can be done to rectify the error? Any other suggestions are also welcome.
Solution
You need to install body-parser module
To install
npm i -s body-parser
Then
Set the below config before app.post route
// support parsing of application/json type post data
app.use(bodyParser.json());
//support parsing of application/x-www-form-urlencoded post
app.use(bodyParser.urlencoded({
parameterLimit: 100000,
limit: '150mb',
extended: true
}));
Answered By - Hemadri Dasari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.