q-uploader:: how to get the response after upload is complete?



  • <q-uploader
      :factory="factoryFn"
      style="max-width: 600px"
      accept=".jpg, image/*"
     />
    
    factoryFn (file) {
          const pro = new Promise((resolve) => {
            resolve({
              url: window.axios.defaults.baseURL + '/upload',
              method: 'POST'
            })
          })
          return pro
        }
    

    The backend will return

    return response(
                    [
                        'url' => request()->getHttpHost() .'/public/profiles/' . $uname,
                        'status' => 'success'
                    ], 
                200);
    

    I would like to get the ‘url’ and status from the backend. Have tried .then((response) => { console.log(response.url) }) after resolve but failed.



  • @ilabutk
    Use the @uploaded event of QUploader.
    The info parameter has a xhr property which hold the XMLHttpRequest used for the uploader.
    You can get your backend response with info.xhr.response



  • @tof06 Thank you for the tip! Worked like a charm.


Log in to reply