-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Hardeepex/sweep/i_want_to_use_ssr_in_astro…
…_project_for_m Sweep: I want to use SSR in astro project for my api (✓ Sandbox Passed)
- Loading branch information
Showing
4 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
import { Fragment } from 'react'; | ||
export async function getStaticProps() { | ||
// Define the API endpoint from which data will be fetched. | ||
const apiEndpoint = 'https://api.example.com/data'; | ||
// Fetch data from the API endpoint using the fetch function. | ||
const response = await fetch(apiEndpoint); | ||
// Parse the response to JSON format. | ||
const data = await response.json(); | ||
// Export the fetched data as props for consumption by other components or pages. | ||
return { props: { data } }; | ||
} | ||
const ApiDataFetcher = ({ data }) => { | ||
// The component does not render any UI elements. | ||
return <Fragment />; | ||
}; | ||
export default ApiDataFetcher; |
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
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
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