Tell us what’s happening:
This project was working correctly when I made it a couple weeks ago, but now I can’t seem to get my GET request with axios working. I’m getting a network error now when I try to send requests. I don’t think I created a bug that broke the app but I’m not entirely sure.
Your code so far
My React Component:
class QuoteBox extends React.Component {
constructor(props) {
super(props);
this.state = {};
this.newQuote = this.newQuote.bind(this);
this.newQuoteHandler = this.newQuoteHandler.bind(this);
this.newQuote();
}
newQuote() {
axios.default.get('https://zenquotes.io/api/random')
.then(res => {
const quote = res[0];
this.setState({
quote: quote.q,
author: quote.a
})
}).catch(function (error) {
console.log(error);
})
}
newQuoteHandler(event) {
event.preventDefault();
this.newQuote();
}
render() {
return (
<div id='quote-box'>
<QuoteText quote={this.state.quote}/>
<QuoteAuthor author={this.state.author}/>
<div id='interactive-row'>
<TweetQuoteBtn quote={{ text: this.state.quote, author: this.state.author }}/>
<NewQuoteBtn newQuoteHandler={this.newQuoteHandler}/>
</div>
</div>
)
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:85.0) Gecko/20100101 Firefox/85.0
.
Challenge: Build a Random Quote Machine
Link to the challenge: