Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DMWT_24WS_Gruppe02
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Frickel
DMWT_24WS_Gruppe02
Commits
8e8d1d35
Unverified
Commit
8e8d1d35
authored
5 months ago
by
SurpriseChan
Committed by
GitHub
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Add files via upload
parent
d5cb4c44
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
2ndPage.js
+44
-0
44 additions, 0 deletions
2ndPage.js
index.js
+22
-0
22 additions, 0 deletions
index.js
with
66 additions
and
0 deletions
2ndPage.js
0 → 100644
+
44
−
0
View file @
8e8d1d35
import
React
,
{
useEffect
,
useState
}
from
'
react
'
;
import
{
useRouter
}
from
'
next/router
'
;
function
ApiPage
()
{
const
[
data
,
setData
]
=
useState
(
null
);
const
router
=
useRouter
();
useEffect
(()
=>
{
fetch
(
'
https://jsonplaceholder.typicode.com/comments
'
)
.
then
((
response
)
=>
response
.
json
())
.
then
((
data
)
=>
setData
(
data
.
slice
(
0
,
10
)))
// Ersten 10 Daten
.
catch
((
error
)
=>
console
.
error
(
'
Error fetching data:
'
,
error
));
},
[]);
const
handleBack
=
()
=>
{
router
.
push
(
'
/
'
);
};
return
(
<
div
>
<
h1
>
API
Seite
<
/h1>
{
data
&&
data
.
length
>
0
?
(
// Prüft ob data frei ist und ob es sachen hat
<
div
>
<
h2
>
Ersten
10
Kommentare
von
der
API
:
<
/h2>
<
button
onClick
=
{
handleBack
}
>
Start
Seite
<
/button>
<
ul
>
{
data
.
map
((
item
)
=>
(
<
li
key
=
{
item
.
id
}
>
<
p
><
strong
>
Kommentar
:
<
/strong> {item.body}</
p
>
<
/li>
))}
<
/ul>
<
/div>
)
:
(
<
p
>
Loading
...
<
/p>
)}
<
/div>
);
}
//<p><strong>Email:</strong> {item.name}</p> //Name
//<p><strong>Email:</strong> {item.email}</p> //Email
export
default
ApiPage
;
This diff is collapsed.
Click to expand it.
index.js
0 → 100644
+
22
−
0
View file @
8e8d1d35
import
React
from
'
react
'
;
import
{
useRouter
}
from
'
next/router
'
;
function
StartPage
()
{
const
router
=
useRouter
();
//Macht das man Seite Wechseln Kann
const
handleNavigate
=
()
=>
{
// Geht zur Zweiten Seite
router
.
push
(
'
/2ndPage
'
);
};
return
(
<
div
>
<
h1
>
Homepage
<
/h1
>
<
button
onClick
=
{
handleNavigate
}
>
Zweite
Seite
<
/button
>
<
li
>
<
img
src
=
"
https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg
"
/>
<
/li
>
<
/div
>
);
}
export
default
StartPage
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment