Can you figure out why the server is returning 'undefined' and 'XMLHttpRequest cannot load the "URL" Response for preflight is invalid (redirect)'?
The app is supposed to send document details to the server through a normal post service, which should return an object with various parameters. However, it's currently returning 'undefined'.
Here is the code snippet for the service used to post the document:
fileUpload: {
method: 'POST',
url: config.apiPath + 'employee/service/pushRecords',
isArray: false,
params: {},
headers: {
'content-type': undefined
}
},
The above service is utilized after creating formdata for the document:
function registerFormdata(files, fieldName) {
files = files || [];
fieldName = fieldName || 'FileSent';
var returnData = new FormData();
_.each(files, function (file, ind) {
returnData.append(fieldName,file);
});
return returnData;
}
Now, let's take a look at the controller where these services are used:
function sendFilesToServer() {
var formData = employeePushService.registerFormdata(directive.dropZoneFile.fileToUpload);
return docUploadService.fileUpload(formData)
.then(function(document) {
// Additional actions are performed here, but in browser console the server response shows Error [undefined]
}).catch(logger.error);
}