We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d73ffb1 commit a1c7d69Copy full SHA for a1c7d69
pages/ninjas/[id].js
@@ -15,10 +15,23 @@ export const getStaticPaths = async () => {
15
}
16
17
18
-const Details = () => {
+export const getStaticProps = async (context) => {
19
+ const id = context.params.id;
20
+ const res = await fetch('https://jsonplaceholder.typicode.com/users/' + id);
21
+ const data = await res.json();
22
+
23
+ return {
24
+ props: { ninja: data }
25
+ }
26
+}
27
28
+const Details = ({ ninja }) => {
29
return (
30
<div>
- <h1>Details Page</h1>
31
+ <h1>{ ninja.name }</h1>
32
+ <p>{ ninja.email }</p>
33
+ <p>{ ninja.website }</p>
34
+ <p>{ ninja.address.city }</p>
35
</div>
36
);
37
0 commit comments