Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
K
kiaisoft_tuananh_nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TTS Tran Viet Anh
kiaisoft_tuananh_nuxt
Commits
28df8be7
Commit
28df8be7
authored
Jan 30, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bearer token
parent
66e7f51a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
52 deletions
+117
-52
nav.vue
components/nav.vue
+1
-1
index.vue
pages/categories/index.vue
+38
-22
index.vue
pages/posts/index.vue
+18
-6
index.vue
pages/products/index.vue
+22
-9
register.vue
pages/register.vue
+1
-1
index.vue
pages/users/index.vue
+37
-13
No files found.
components/nav.vue
View file @
28df8be7
...
...
@@ -56,7 +56,7 @@ export default {
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
accept
:
"
application/json
"
,
"
accept
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
({
token
:
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
),
...
...
pages/categories/index.vue
View file @
28df8be7
...
...
@@ -308,7 +308,11 @@ export default {
},
getCategories
()
{
this
.
$axios
.
get
(
"
/categories/
"
)
.
get
(
"
/categories/
"
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -319,17 +323,20 @@ export default {
const
image
=
Array
.
from
(
set
)
const
self
=
this
this
.
$axios
.
post
(
'
/categories/
'
,{
name
:
this
.
name
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
images
:
image
,
},
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
"
Authorization
"
:
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)
.
post
(
'
/categories/
'
,
{
name
:
this
.
name
,
ordering
:
this
.
ordering
,
parent_id
:
this
.
parent_id
,
images
:
image
,
},
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
}
}
)
)
.
then
(
response
=>
{
this
.
$bvModal
.
hide
(
'
modal-create
'
)
self
.
$toast
.
success
(
'
Category created successfully!
'
,
{
...
...
@@ -362,7 +369,13 @@ export default {
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
this
.
$axios
.
delete
(
`/categories/
${
ID
}
`
)
.
delete
(
`/categories/
${
ID
}
`
,
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
})
.
then
(
response
=>
{
this
.
categories
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,{
...
...
@@ -397,16 +410,19 @@ export default {
console
.
log
(
this
?.
eID
)
try
{
this
.
$axios
.
post
(
`categories/update/
${
this
?.
eID
}
`,{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
images: image }, {
headers: {
"Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token")
}
} )
.
post
(
`categories/update/
${
this
?.
eID
}
`,
{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
images: image },
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`,
}
}
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
...
...
pages/posts/index.vue
View file @
28df8be7
...
...
@@ -386,7 +386,11 @@ export default {
},
getCategories
()
{
this
.
$axios
.
get
(
"
/categories/
"
)
.
get
(
"
/categories/
"
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -394,7 +398,11 @@ export default {
},
getposts
()
{
this
.
$axios
.
get
(
"
/posts/
"
)
.
get
(
"
/posts/
"
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
posts
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -415,7 +423,7 @@ export default {
{
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
}
)
...
...
@@ -442,7 +450,11 @@ export default {
this
.
editedIndex
=
this
.
posts
.
indexOf
(
index
)
if
(
confirm
(
"
Do you really want to delete?
"
))
{
this
.
$axios
.
delete
(
`/posts/
${
ID
}
`
)
.
delete
(
`/posts/
${
ID
}
`
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
{
this
.
posts
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
"
Post deleted successfully!
"
,
{
...
...
@@ -464,7 +476,7 @@ export default {
method
:
"
GET
"
,
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
})
console
.
log
(
resp
.
data
)
...
...
@@ -505,7 +517,7 @@ export default {
{
headers: {
"Content-Type": "multipart/form-data",
Authorization:
this.$auth.$storage.getUniversal("token")
,
Authorization:
`
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
}
)
...
...
pages/products/index.vue
View file @
28df8be7
...
...
@@ -487,7 +487,11 @@ export default {
},
getCategories
()
{
this
.
$axios
.
get
(
"
/categories/
"
)
.
get
(
"
/categories/
"
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
categories
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -495,7 +499,11 @@ export default {
},
getProducts
()
{
this
.
$axios
.
get
(
"
/products/
"
)
.
get
(
"
/products/
"
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
((
response
)
=>
(
this
.
products
=
response
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -516,7 +524,7 @@ export default {
},
{
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
'
Authorization
'
:
this
.
$auth
.
$storage
.
getUniversal
(
'
token
'
)
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}
})
.
then
(
response
=>
{
...
...
@@ -543,7 +551,11 @@ export default {
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
this
.
$axios
.
delete
(
`/products/
${
ID
}
`
)
.
delete
(
`/products/
${
ID
}
`
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
}})
.
then
(
response
=>
{
this
.
products
.
splice
(
this
.
editedIndex
,
1
)
self
.
$toast
.
success
(
'
Category deleted successfully!
'
,{
...
...
@@ -562,7 +574,7 @@ export default {
method
:
"
GET
"
,
headers
:
{
"
Content-Type
"
:
"
multipart/form-data
"
,
Authorization
:
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
})
this
.
sName
=
resp
.
data
.
data
.
name
...
...
@@ -600,11 +612,12 @@ export default {
images: this.eImages,
variants: this.eVariants,
}, {
headers: {
"Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token")
headers: {
"Content-Type": "multipart/form-data",
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`,
}
}
}
)
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
...
...
pages/register.vue
View file @
28df8be7
...
...
@@ -86,7 +86,7 @@ export default {
confirm_password
:
this
.
confirm_password
,
}),
});
this
.
$router
.
push
(
"
/
"
);
this
.
$router
.
push
(
"
/
login
"
);
},
},
};
...
...
pages/users/index.vue
View file @
28df8be7
...
...
@@ -295,7 +295,12 @@ export default {
},
getUsers
()
{
this
.
$axios
.
get
(
'
/users/
'
)
.
get
(
'
/users/
'
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
})
.
then
((
response
)
=>
(
this
.
users
=
response
.
data
.
data
.
data
))
.
catch
(
function
(
error
)
{
console
.
log
(
error
)
...
...
@@ -304,14 +309,19 @@ export default {
createUser
()
{
const
self
=
this
this
.
$axios
.
post
(
'
/users/
'
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
.
post
(
'
/users/
'
,
{
email
:
this
.
email
,
password
:
this
.
password
,
name
:
this
.
name
,
},
email
:
this
.
email
,
password
:
this
.
password
,
name
:
this
.
name
,
})
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
}
)
.
then
(
response
=>
{
// $bvModal.hide('modal-login');
this
.
$bvModal
.
hide
(
'
modal-login
'
)
...
...
@@ -338,7 +348,12 @@ export default {
if
(
confirm
(
"
Do you really want to delete?
"
)){
try
{
this
.
$axios
.
delete
(
`/users/
${
userID
}
`
)
.
delete
(
`/users/
${
userID
}
`
,{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Authorization
:
`Bearer
${
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`
,
},
})
.
then
(
response
=>
{
console
.
log
(
response
.
data
)
this
.
users
.
splice
(
this
.
editedIndex
,
1
)
...
...
@@ -366,10 +381,19 @@ export default {
console
.
log
(
this
?.
eID
)
try
{
this
.
$axios
.
put
(
`/users/
${
this
?.
eID
}
`,{
email: this.eEmail,
password: this.ePassword,
name:this.eName,} )
.
put
(
`/users/
${
this
?.
eID
}
`,
{
email: this.eEmail,
password: this.ePassword,
name:this.eName,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `
Bearer
$
{
this
.
$auth
.
$storage
.
getUniversal
(
"
token
"
)}
`,
},
}
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment