I am very new to react and I am having issues when it comes to passing data from one method to another method. Here is my react syntax:
var url = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1"
class App extends React.Component{
info(val){
console.log(val)
}
request(){
axios.get(url)
.then(function (response) {
this.info(response)
console.log(response.data);
})
}
render() {
return(
<div>
<h1>axios</h1>
{this.request()}
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById("target"))
My goal is to pass the response data from request
method to info
method. However, I am getting error saying that "TypeError: Cannot read property 'info' of undefined"
Can you help me identify what I am missing?