Skip to content

Commit

Permalink
Run Prettier on QuoteOfTheDay.js
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrocuzzocrea committed Feb 3, 2018
1 parent d30f1c9 commit ec1efcb
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/components/QuoteOfTheDay.js
@@ -1,44 +1,44 @@
import React from 'react';
import React from "react";

import { QuotesRESTAPIUrl } from '../consts';
import { QuotesRESTAPIUrl } from "../consts";

class QuoteOfTheDay extends React.Component {
constructor() {
super();

constructor() {
super();

this.state = {
quote: { quote: "Loading...", author: null },
};
}

componentWillMount() {

this.getQuote().then(quote => this.setState({ quote }));
}

getQuote = async () => {

try {
const res = await fetch(QuotesRESTAPIUrl);
const data = await res.json();
const { quote, author } = data['contents']['quotes'][0];
return { quote, author };
} catch (e) {
return { quote: `GET ${QuotesRESTAPIUrl} 429 (Too Many Requests)`, author: "quotes.rest" };
}
this.state = {
quote: { quote: "Loading...", author: null }
};

render() {

const { quote, author } = this.state.quote;

return (
<div id="quoteOfTheDay">
<p>{quote}</p>{(author !== null) ? <p className="author">{author}</p> : null}
</div>
);
}

componentWillMount() {
this.getQuote().then(quote => this.setState({ quote }));
}

getQuote = async () => {
try {
const res = await fetch(QuotesRESTAPIUrl);
const data = await res.json();
const { quote, author } = data["contents"]["quotes"][0];
return { quote, author };
} catch (e) {
return {
quote: `GET ${QuotesRESTAPIUrl} 429 (Too Many Requests)`,
author: "quotes.rest"
};
}
};

render() {
const { quote, author } = this.state.quote;

return (
<div id="quoteOfTheDay">
<p>{quote}</p>
{author !== null ? <p className="author">{author}</p> : null}
</div>
);
}
}

export default QuoteOfTheDay;

0 comments on commit ec1efcb

Please sign in to comment.