Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spring2021-SellPoint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
Martin Immanuel Burgos
Spring2021-SellPoint
Commits
77b4f561
Commit
77b4f561
authored
4 years ago
by
Tormod Nygård
Browse files
Options
Downloads
Patches
Plain Diff
Issue: Fix "categoryid" in backend (#4)
Co-authored-by:
Hanna Pelsholen Busterud
<
hannapb@ntnu.no
>
parent
200bf5be
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/src/controllers/postcontroller/index.ts
+3
-3
3 additions, 3 deletions
server/src/controllers/postcontroller/index.ts
server/src/models/post.ts
+1
-1
1 addition, 1 deletion
server/src/models/post.ts
with
4 additions
and
4 deletions
server/src/controllers/postcontroller/index.ts
+
3
−
3
View file @
77b4f561
...
...
@@ -11,18 +11,18 @@ const category = new Category();
// Create posts `/api/post/`
//'{"title":"test3","description":"test3","timestamp":123123,"owner":"test3","category":"test3","imageUrl":"test3"}'
router
.
route
(
'
/
'
).
post
(
async
(
request
:
Request
,
response
:
Response
)
=>
{
const
{
title
,
description
,
timestamp
,
owner
,
category
,
imageUrl
}
=
request
.
body
;
const
{
title
,
description
,
timestamp
,
owner
,
category
id
,
imageUrl
}
=
request
.
body
;
try
{
const
post
:
IPost
=
{
"
title
"
:
title
,
"
description
"
:
description
,
"
timestamp
"
:
timestamp
,
"
owner
"
:
owner
,
"
category
"
:
category
,
"
category
id
"
:
category
id
,
"
imageUrl
"
:
imageUrl
};
if
(
Object
.
values
(
post
).
filter
(
p
=>
p
==
undefined
).
length
>
0
)
return
response
.
status
(
500
).
send
(
"
Error
"
);
const
input
=
(
`INSERT INTO post(title, description, timestamp, owner, category, imageUrl) VALUES (?,?,?,?,?,?)`
)
const
input
=
(
`INSERT INTO post(title, description, timestamp, owner, category
id
, imageUrl) VALUES (?,?,?,?,?,?)`
)
return
response
.
status
(
200
).
json
(
await
query
(
input
,
Object
.
values
(
post
))
);
...
...
This diff is collapsed.
Click to expand it.
server/src/models/post.ts
+
1
−
1
View file @
77b4f561
...
...
@@ -4,7 +4,7 @@ interface IPost {
description
:
string
;
timestamp
:
number
;
owner
:
string
;
category
:
string
;
category
id
:
number
;
imageUrl
:
string
;
}
...
...
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