I am facing difficulty when I am using one axios request in another. Especially when the response.data array is empty. Whenever response.data array is empty it gives me this error:-
Uncaught (in promise) TypeError: Cannot read property 'data' of undefined
I know many people have asked Uncaught but not with response.data Here is my code:-
axios.get(URL+'/xyz?variable='+variablevalue, headerconfig)
.then(response => {
this.tempvariable= (response.data);
axios.get(URL+'/abc?variable='+variablevalue,headerconfig)
.then((response) => {
this.tempvariable = (response.data);
//inside for loop by using this.tempvariable
this.some_variable= this.anothervari.reduce((a,b) => Number(a) > Number(b) ? a : b);
})
.catch(e => {
alert(e.response.data);
})
})
.catch(e => {
alert(e.response.data);
})
console.log(response)
? – Ankit Agarwal{data: Array(0), status: 200, statusText: "OK", headers: {…}, config: {…}, …}
– JustStartedProgramming