Yes
Upload
After upload failed, the on-error event is triggered, but I don't find the server response in its parameters. Can I get the http status code somehow, or it's an issue now?
It works fine for me. In one of my recent projects I had something like this:
<el-upload :on-error="onUploadError" action="xxx"></el-upload>
onUploadError(err) {
if (err.status === 401) {
this.$message.error('Please login before uploading')
}
}
Please make sure you're using it right and the server returns what you need.
hi, @Leopoldthecoder , I can't get the response content in the 'on-error' callback, I print the err object like this ([email protected]):
onUploadError(err) {
console.log(JSON.parse(JSON.stringify(err)))
}
the result is:
Object {status: 400, method: "post", url: "/api/upload-something"}
Is there any way to get the response content?
Is there any way to get the response content?
@jwma
uploadErr: function(err, file, fileList) {
this.$message.error('upload fail:'+JSON.parse(err.message).errmsg)
},
As I know now, the error
param is depends on your server.
For example if your server give a 404 html back for an invalid url, the error will be an html string.
Most helpful comment
hi, @Leopoldthecoder , I can't get the response content in the 'on-error' callback, I print the err object like this ([email protected]):
onUploadError(err) { console.log(JSON.parse(JSON.stringify(err))) }
the result is:
Object {status: 400, method: "post", url: "/api/upload-something"}
Is there any way to get the response content?