fortana-co / react-dropzone-uploader

React file dropzone and uploader
https://react-dropzone-uploader.js.org/
MIT License
447 stars 183 forks source link

How can i get response back in my uploader component? i don't want to changes any file in node-modules #123

Open zulqarnain-26 opened 4 years ago

zulqarnain-26 commented 4 years ago

Hi! my server returns an id in response but i don't know how to receive that id on front end without disturbing the react-dropzone-uploader files in node-modules? Any leads?

Balavamsi1999 commented 4 years ago

@zulqarnain-26 @kylebebak Facing the same problem , please help..

Balavamsi1999 commented 4 years ago

change the handle Change Status function ::: we can get the response by xhr.response

` const handleChangeStatus = ({ meta, file,xhr }, status) => { // called every time a files status changes console.log("handleStatus",status, meta, file) if(status == "done") { var json = JSON.parse(xhr.response) var arr = state.documents_blob_ids.slice() console.log("id added",json.blob.id) if (json.blob.id){ arr.push(json.blob.id) setState({...state,documents_blob_ids: arr}) } }

  if(status == "removed") {
    var json = JSON.parse(xhr.response)
    var arr = state.documents_blob_ids.slice()
    console.log("id removed",json.blob.id)
    if (json.blob.id){
      arr.filter( v => v!= json.blob.id)
      setState({...state,documents_blob_ids: arr})
    }       
  }

}`
zulqarnain-26 commented 4 years ago

Thanks

On Sat, Sep 12, 2020 at 10:58 AM Balavamsi1999 notifications@github.com wrote:

change the handle Change Status function ::: we can get the response by xhr.response

const handleChangeStatus = ({ meta, file,xhr }, status) => { // called every time a file's status changes console.log("handleStatus",status, meta, file) if(status == "done") { var json = JSON.parse(xhr.response) var arr = state.documents_blob_ids.slice() console.log("id added",json.blob.id) if (json.blob.id){ arr.push(json.blob.id) setState({...state,documents_blob_ids: arr}) } }

if(status == "removed") { var json = JSON.parse(xhr.response) var arr = state.documents_blob_ids.slice() console.log("id removed",json.blob.id) if (json.blob.id){ arr.filter( v => v!= json.blob.id) setState({...state,documents_blob_ids: arr}) } }

}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fortana-co/react-dropzone-uploader/issues/123#issuecomment-691419948, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP5U757VHL7NASOR4RGNIU3SFMEYVANCNFSM4RHJP7YA .