I am working on API creation for a mobile native app and need to create a REST API to upload a user profile pic. But when I am trying to upload the image in a POST request it's showing undefined.
This is my code in the app/server/server.js file:
if(Meteor.isServer) {
Router.route('/api/uploadpic/', { where: 'server' })
.post(function () {
let response;
console.log(this.request.body.file);
this.response.setHeader('Content-Type', 'application/json');
this.response.end(JSON.stringify(response));
});
}
After spending a lot of hours I did not get anything useful. Do I need to use any package for this? Postman api request http://prntscr.com/ojfcvj
Not sure if it helps but try to change Content Type from application/json to 'multipart/form-data'