No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Help
    2
    3
    630
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      ilabutk last edited by

      <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.

      T 1 Reply Last reply Reply Quote 0
      • T
        tof06 @ilabutk last edited by

        @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

        1 Reply Last reply Reply Quote 0
        • I
          ilabutk last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post