I have a search bar with a button. when the button is clicked, the search_on_click function runs. This function is supposed to retrieve the html of the URL and display it on the page.
class App extends Component{
constructor(props){
super(props)
this.state = {
html: []
}
this.search = this.search.bind(this)
}
search(){
const URL = 'https://www.zerochan.net/Re%3AZero+Kara+Hajimeru+Isekai+Seikatsu?s=fav'
axios.get(URL)
.then(data =>{
console.log(data)
this.setState({
query: data
})
})
.catch(function(error){
console.log(error);
})
}
render(){
return(
<div>
<button onClick={() => this.search()}>search</button>
<div>{this.state.query}</div>
</div>
This is the code i have so far. The problems/questions are:
axios does not console.log the html or even seem to run
i have tried fetch/requests and the problems are more or less the same
- is there a better way to do this?
- i do not think the is a CORS problem because i have used CORS allowing chrome extension.
- .catch() does not log anything to console either
thank you for your time.