0

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?

1 Answer 1

0

Alright, I found out what was the issue: the response from the server was in a form of string, not a JSON.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.