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 ofQUploader
.
Theinfo
parameter has axhr
property which hold theXMLHttpRequest
used for the uploader.
You can get your backend response withinfo.xhr.response
-
@tof06 Thank you for the tip! Worked like a charm.