I am a beginner in coding just started with node.js ,I want to send an excel file from client side to server side using ajax post method. But while trying this code I am getting error 'BadRequestError: Only json objects or array allowed'. Can someone please tell me what I am doing wrong here.
<div>
<input type="file" name="myFile" id="myFile" multiple/>
<input type="button" value="Upload" ng-click ="fileUpload($event)">
</div>
$scope.fileUpload = function() {
const myFile = document.getElementById("myFile").files;
var formData = new FormData();
for (var i =0; i<myFile.length; i++) {
formData.append("myFile", myFile[i]);
}
dataFactory.post("/excel.json", formData).then(function(res) {
console.log(res);
}, function() {
});
};
Error :POST http://localhost:5000//excel.json 500 (Internal Server Error)