Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DMWT_Season10_Group_2
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
Sven Holm
DMWT_Season10_Group_2
Commits
4ec5b0bb
Commit
4ec5b0bb
authored
1 year ago
by
Tim-Luca Taxis
Browse files
Options
Downloads
Patches
Plain Diff
changed
parent
e138540a
No related branches found
No related tags found
1 merge request
!4
added vercel integration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dmwt_session10/src/components/FruitList.js
+3
-3
3 additions, 3 deletions
dmwt_session10/src/components/FruitList.js
dmwt_session10/src/pages/API/list-fruits.js
+2
-2
2 additions, 2 deletions
dmwt_session10/src/pages/API/list-fruits.js
with
5 additions
and
5 deletions
dmwt_session10/src/components/FruitList.js
+
3
−
3
View file @
4ec5b0bb
...
...
@@ -4,7 +4,7 @@ import useSWR from 'swr';
const
fetcher
=
url
=>
fetch
(
url
).
then
(
res
=>
res
.
json
());
const
FruitList
=
()
=>
{
const
{
data
:
fruits
,
isLoading
,
error
,
mutate
}
=
useSWR
(
'
/api/list-fruits
'
,
fetcher
,
{
const
{
data
:
fruits
,
error
}
=
useSWR
(
'
/api/list-fruits
'
,
fetcher
,
{
revalidateOnFocus
:
false
,
revalidateOnReconnect
:
false
,
});
...
...
@@ -13,13 +13,13 @@ const FruitList = () => {
return
<
p
>
Failed
to
fetch
<
/p>
;
}
if
(
isLoading
)
{
if
(
!
fruits
)
{
return
<
p
>
Loading
fruits
...
<
/p>
;
}
return
(
<
ul
>
{
fruits
&&
fruits
.
length
>
0
?
(
{
fruits
.
length
>
0
?
(
fruits
.
map
((
fruit
,
index
)
=>
(
<
li
key
=
{
index
}
>
{
fruit
[
'
Deutscher Name
'
]}
({
fruit
[
'
Lateinischer Name
'
]}),
{
fruit
.
Farbe
},
{
fruit
.
Herkunft
},
{
fruit
.
Kalorien
}
kcal
...
...
This diff is collapsed.
Click to expand it.
dmwt_session10/src/pages/API/list-fruits.js
+
2
−
2
View file @
4ec5b0bb
...
...
@@ -3,8 +3,8 @@ import { sql } from '@vercel/postgres';
export
default
async
function
handler
(
request
,
response
)
{
if
(
request
.
method
===
'
GET
'
)
{
try
{
const
fruits
=
await
sql
`SELECT * FROM obst;`
;
return
response
.
status
(
200
).
json
(
fruits
.
rows
);
// Ensure you return the rows
const
{
rows
:
fruits
}
=
await
sql
`SELECT * FROM obst;`
;
return
response
.
status
(
200
).
json
(
fruits
);
}
catch
(
error
)
{
console
.
error
(
'
Error during request processing:
'
,
error
);
return
response
.
status
(
500
).
json
({
error
:
error
.
message
});
...
...
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