Cannot read property 'protocol' of undefined : axios react

徘徊边缘 提交于 2019-12-11 14:29:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!