Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dummy Frontend
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Examples
Javascript
Dummy Frontend
Commits
fd2737ec
Commit
fd2737ec
authored
Dec 26, 2022
by
Dmitriy Safronov
Browse files
Options
Downloads
Patches
Plain Diff
api/users
parent
3fd7e6e3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/App.js
+28
-6
28 additions, 6 deletions
src/App.js
with
28 additions
and
6 deletions
src/App.js
+
28
−
6
View file @
fd2737ec
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
ReactDOM
from
"
react-dom
"
;
import
logo
from
'
./logo.svg
'
;
import
'
./App.css
'
;
function
App
()
{
const
[
users
,
setUsers
]
=
useState
();
// Function to collect data
const
getApiData
=
async
()
=>
{
const
response
=
await
fetch
(
"
/api/users
"
).
then
((
response
)
=>
response
.
json
());
setUsers
(
response
);
};
useEffect
(()
=>
{
getApiData
();
},
[]);
return
(
<
div
className
=
"
App
"
>
<
header
className
=
"
App-header
"
>
<
img
src
=
{
logo
}
className
=
"
App-logo
"
alt
=
"
logo
"
/>
<
p
>
Edit
<
code
>
src
/
App
.
js
<
/code> and save to reload
.
<
/p
>
<
a
className
=
"
App-link
"
href
=
"
https://reactjs.org
"
href
=
"
/
"
target
=
"
_blank
"
rel
=
"
noopener noreferrer
"
>
Learn
React
<
img
src
=
{
logo
}
className
=
"
App-logo
"
alt
=
"
logo
"
/>
<
/a
>
<
p
>
{
users
&&
users
.
map
((
user
)
=>
(
<
div
className
=
"
item-container
"
>
Id
:{
user
.
id
}
<
div
className
=
"
title
"
>
Title
:{
user
.
title
}
<
/div
>
<
/div
>
))}
<
/p
>
<
/header
>
<
/div
>
);
...
...
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