diff --git a/pages/index.js b/pages/index.js index d2dad56..e04ad31 100644 --- a/pages/index.js +++ b/pages/index.js @@ -58,12 +58,15 @@ export async function getServerSideProps() { const posts = getAllPosts(); - await fetch(`https://api.ethancedwards.com/quotes/v1`).then((res) => { - final = res; - }).catch((error) => { - quotes = { quote: "Value your freedom or you will lose it, teaches history", author: "Richard Stallman" }; + // await fetch(`https://api.ethancedwards.com/quotes/v1`).then((res) => { + await fetch(`http://localhost/quotes/v1`).then((res) => { + if (!res.ok) { + final = { quote: "Value your freedom or you will lose it, teaches history", author: "Richard Stallman" }; + } else { + final = res.json(); + } }); - quotes = await final.json(); + quotes = await final; return { props: { quotes, posts } }; }