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
817ac51e
Commit
817ac51e
authored
Dec 28, 2022
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get data response
parent
e683fb3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
nav.vue
components/nav.vue
+3
-1
index.vue
pages/index.vue
+16
-4
No files found.
components/nav.vue
View file @
817ac51e
...
@@ -48,6 +48,7 @@ export default {
...
@@ -48,6 +48,7 @@ export default {
</
script
>
</
script
>
<
script
>
<
script
>
const
token
=
localStorage
.
getItem
(
'
bgcolor
'
);
export
default
{
export
default
{
name
:
"
logout
"
,
name
:
"
logout
"
,
data
()
{
data
()
{
...
@@ -55,7 +56,7 @@ export default {
...
@@ -55,7 +56,7 @@ export default {
users
:
[],
users
:
[],
}
}
},
},
methods
:
{
methods
:
{
logout
()
{
logout
()
{
fetch
(
"
http://127.0.0.1:8000/api/logout
"
,
{
fetch
(
"
http://127.0.0.1:8000/api/logout
"
,
{
...
@@ -64,6 +65,7 @@ export default {
...
@@ -64,6 +65,7 @@ export default {
"
Content-Type
"
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
,
},
},
body
:
JSON
.
stringify
({
body
:
JSON
.
stringify
({
bearer_token
:
token
,
}),
}),
});
});
this
.
$router
.
push
(
'
/
'
);
this
.
$router
.
push
(
'
/
'
);
...
...
pages/index.vue
View file @
817ac51e
...
@@ -82,8 +82,8 @@ export default {
...
@@ -82,8 +82,8 @@ export default {
};
};
},
},
methods
:
{
methods
:
{
login
()
{
async
login
()
{
fetch
(
"
http://127.0.0.1:8000/api/login
"
,
{
var
resp
=
await
fetch
(
"
http://127.0.0.1:8000/api/login
"
,
{
method
:
"
POST
"
,
method
:
"
POST
"
,
headers
:
{
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
,
...
@@ -92,8 +92,20 @@ export default {
...
@@ -92,8 +92,20 @@ export default {
email
:
this
.
email
,
email
:
this
.
email
,
password
:
this
.
password
,
password
:
this
.
password
,
}),
}),
});
}).
then
((
response
)
=>
{
this
.
$router
.
push
(
'
home
'
);
return
response
.
json
();
if
(
resp
.
data
.
bearer_token
){
this
.
$router
.
push
(
'
home
'
);
}
});
console
.
log
(
resp
.
data
.
bearer_token
)
// localStorage.setItem('bgcolor', resp.data.bearer_token);
await
this
.
$auth
.
setToken
(
'
local
'
,
"
Bearer
"
+
resp
.
data
.
bearer_token
);
await
this
.
$auth
.
setRefreshToken
(
'
local
'
,
resp
.
data
.
refresh
);
await
this
.
$auth
.
setUserToken
(
resp
.
data
.
access
);
},
},
},
},
};
};
...
...
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