Last active
August 22, 2023 13:40
-
-
Save tahacankurt/6a206695f1a12513144923ab56f8b1f6 to your computer and use it in GitHub Desktop.
Next.js Get Initial Props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Articles.getInitialProps = async function() { | |
const apiPath = "https://newsapi.org/v2/"; | |
const res = await fetch(`${apiPath}everything?q=bitcoin&from=2019-11-02&sortBy=publishedAt&apiKey=<ApiKey>`); | |
const data = await res.json(); | |
return { | |
articles: data.articles | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment