I have an issue with ploading a file to my server. I follow the structure provided in the demos:
file.upload = this.Upload.upload({
url: "/api/license/upload",
method: "POST",
data: {
name:file.name
},
file: file
}).then(function (resp:any) {
console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
}, function (resp:any) {
console.log('Error status: ' + resp.status);
}, function (evt:any) {
var progressPercentage = parseInt(evt.loaded / evt.total);
console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
}
However, when I am trying to upload a file, in a response from a server I get 200 (which is OK), but then the app crashes with the following:
SyntaxError: Unexpected token Y
at Object.parse (native)
at vc (http://localhost:4000/dist/vendor.min.js:20:480)
at Zb (http://localhost:4000/dist/vendor.min.js:87:229)
at http://localhost:4000/dist/vendor.min.js:88:143
at m (http://localhost:4000/dist/vendor.min.js:12:322)
at dd (http://localhost:4000/dist/vendor.min.js:88:125)
at d (http://localhost:4000/dist/vendor.min.js:89:380)
at http://localhost:4000/dist/vendor.min.js:124:113
at n.$eval (http://localhost:4000/dist/vendor.min.js:138:221)
at n.$digest (http://localhost:4000/dist/vendor.min.js:135:233)
Any ideas on what might be the problem?
Alright, I found out what was the issue: the response from the server was in a form of string, not a JSON.