Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bloglist
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
Service Desk
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
Admin message
Maintenance moved to Monday 17.3. at 13:00. ETA 60 - 90 minutes.
Show more breadcrumbs
Viivi Nevalainen
bloglist
Commits
99c5f17d
Commit
99c5f17d
authored
1 year ago
by
Viivi Nevalainen
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
8f31423d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bloglist_frontend/src/blogs.js
+35
-0
35 additions, 0 deletions
bloglist_frontend/src/blogs.js
with
35 additions
and
0 deletions
bloglist_frontend/src/blogs.js
0 → 100644
+
35
−
0
View file @
99c5f17d
import
axios
from
'
axios
'
const
baseUrl
=
'
/api/blogs
'
let
token
=
null
const
setToken
=
newToken
=>
{
token
=
`bearer
${
newToken
}
`
}
const
getAll
=
()
=>
{
const
request
=
axios
.
get
(
baseUrl
)
return
request
.
then
(
response
=>
response
.
data
)
}
const
create
=
async
newObject
=>
{
const
config
=
{
headers
:
{
Authorization
:
token
},
}
const
response
=
await
axios
.
post
(
baseUrl
,
newObject
,
config
)
return
response
.
data
}
const
update
=
(
id
,
newObject
)
=>
{
const
request
=
axios
.
put
(
`
${
baseUrl
}
/
${
id
}
`
,
newObject
)
return
request
.
then
(
response
=>
response
.
data
)
}
const
poista
=
(
id
)
=>
{
const
request
=
axios
.
delete
(
`
${
baseUrl
}
/
${
id
}
`
)
return
request
.
then
(
response
=>
response
.
data
)
}
// eslint-disable-next-line import/no-anonymous-default-export
export
default
{
getAll
,
create
,
update
,
setToken
,
poista
}
\ No newline at end of file
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