I am sending form-data
along with image-data
.
But I am unable to get data on the node server when sent inside FormData
.
I could see data on the angular
controller on console.log
.
angular code:
$scope.saveInfo = function(){
var formData = new FormData;
console.log('Update function');
for(key in $scope.seller){
formData.append(key, $scope.seller[key]);
}
console.log(key, $scope.seller);
var file = $('#file')[0].files[0];
formData.append('image', file);
$http.put('/api/seller/businessInformation', formData, {
transformRequest: angular.Identity,
headers: {
'Content-type': undefined
}
}).then(function(res){
});
}
Node.Js:
I could see image data on console.log(req.files);
,
but console.log(req.body);
prints [object object].
The problem is with the ng-model data binding.
I was binding data like this: 'seller.a.b.c'
Instead I did seller.a
and it worked.