How can i get the response of a uploader?



  • hi
    i am using q-uploader, i have already upload files but i don’t know how to get a json response that php is sending back… i have a @uploaded=“fileUploaded” listener:

    fileUploaded(file, xhr) {
    console.log(“Success upload”,file,xhr)
    this.$refs.uploader.reset();
    },

    i thougth that xhr argument would contain my json, i have checked in the browser console and the response properties like “response”, “response type” and “response text” are empty

    i can see my json returned in the network panel… but i don’t know how to access it
    anyone knows how?
    thanks for your time.



  • you can get it by accessing xhr “xhr.response”
    e.g.
    fileUploaded(file, xhr) {
    console.log(xhr.response)
    this.$refs.uploader.reset();
    },
    hope this helps 🙂



  • what works for me was:

    fileUploaded(file, xhr) {
    let response = JSON.parse(xhr.response)

    }



  • The response was received as an XMLHttpRequest object in the ‘file’ object.
    What I did was
    var r =new XMLHttpRequest()
    r = file.xhr
    console.log(r.response)



  • @uploaded -> function(info) has a Parameter “info” which has wo props: “files” and “xhr”.
    When you are doing following it works.

    In the QUploader:
    @uploaded=“fileUploaded”

    and in the methods:
    fileUploaded ({ files, xhr }) {
    console.log(JSON.parse(xhr.response))
    }


Log in to reply