问题
const config = {
headers: { "Content-Type": "application/octet-stream"} .
}
let files = this.state.files
let promises = []
files.map((item ,index)=>{
promises.push(axios.put(this.props.deal.authURL[index] , item , config))
})
I get this error - Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined
My aim is to store all the result of the axios calls inside promises array.
And then use Promise.all() function to resolve all at once. Can't figure why the error is there.
Any sort of help is appreciated . Thanks
回答1:
this.props.deal.authURL[index] was returning an undefined url and that was the reason for the random error.
来源:https://stackoverflow.com/questions/47752259/cannot-read-property-protocol-of-undefined-axios-react