Open CarlosCamposGalo opened 7 years ago
As of now I added a workaround as below but I am hoping there should be like this inside upload method to avoid sending "null" string to server:
var objectCleanUp = function (obj) {
var propNames = Object.getOwnPropertyNames(obj);
for (var i = 0; i < propNames.length; i++) {
var propName = propNames[i];
if (obj[propName] === null || obj[propName] === undefined) {
delete obj[propName];
}
}
}
var form ={
data : {
field1: null,
field2: 'Something'
}
}
objectCleanUp(form.data)
Upload.upload({
url: appRoot + 'api/casefiles/' + dialogCtrl.model.id + '/arrestedpersons'
data: form
})
.then()
.catch()
Can anything be done for this one, because $http.post is sending null as nil to the server but this angular upload sends it as 'null' as a string.
I'm having the same situation Any workarounds ?
Did this ever get resolved? I have just come across this now and have been pulling my hair out thinking it was a Laravel issue.
I'm having the same situation
Some answer?
@eduardojesustun, I added the workaround mentioned above by CarlosCamposGalo and it worked for me. I just pass the object through the Cleanup routine before sending it as part of the Upload
method and all nulls
are handled correctly.
I haven't heard of a fix as yet, but the workaround is working for me and has for quite some time now.
@RipleWare Thank you, I will choose to carry out the same process, I have many forms to apply it to
Consider uploading a file with json
this will be sent in a form
In the server side data.field1 = "null" string not null