0

I've been struggling to get the response when i am uploading multiple images.The API is supposed to send me some response.(However,on uploading a single image,I am getting a valid response.) Here is the code:

fileChangedHandler = (event) => {
    const {files} = this.state
    this.setState({ files: [...files, ...event.target.files] })
    const uploaders = files.map(file=>{
        let data = new FormData()
        data.append('image',file)
        return  axios.post('/web/v1.0/upload',data,{
            onUploadProgress: function (progressEvent) {
              console.log(Math.floor((progressEvent.loaded * 100) / progressEvent.total));}
            }).then(response=>{
            console.log(response.data)
        }).catch(error=>{
            console.log(error.response.data)
        })
    })
    axios.all(uploaders).then(() => {

        console.log("All images uploaded")
      });
  } 

I am just getting "All images uploaded" in the console.

Abhinav
  • 34
  • 2
  • 8

1 Answers1

0

Try putting a response variable inside the callback.

axios.all(uploaders).then((response) => {

 console.log("All images uploaded", response)

});

Ideally, response should be an array of strings.