From 389a8bfdb87f0a85e13b51fbed90fee5367c8094 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Fri, 20 Mar 2020 21:56:42 +0000 Subject: [PATCH] add april fools --- src/components/Quote.jsx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/components/Quote.jsx b/src/components/Quote.jsx index 68412ba8..43587364 100644 --- a/src/components/Quote.jsx +++ b/src/components/Quote.jsx @@ -12,13 +12,27 @@ export default class Quote extends React.Component { } async getQuote() { + // Taken from Greeting.jsx + const t = new Date(); // Current date object + const m = t.getMonth(); // Current month + const d = t.getDate(); // Current Date + try { // First we try and get a quote from the API... - let data = await fetch('https://api.muetab.xyz/getQuote'); - data = await data.json(); - this.setState({ - quote: data.quote, - author: data.author - }); + if (m === 3 && d === 1) { // April fools! + let data = await fetch('https://api.kanye.rest'); + data = await data.json(); + this.setState({ + quote: data.quote, + author: 'Kanye West' + }); + } else { + let data = await fetch('https://api.muetab.xyz/getQuote'); + data = await data.json(); + this.setState({ + quote: data.quote, + author: data.author + }); + } } catch (e) { // ..and if that fails we load one locally const quote = Quotes.random(); // Get a random quote from our local package this.setState({