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
Show 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 {
</
script
>
<
script
>
const
token
=
localStorage
.
getItem
(
'
bgcolor
'
);
export
default
{
name
:
"
logout
"
,
data
()
{
...
...
@@ -64,6 +65,7 @@ export default {
"
Content-Type
"
:
"
application/json
"
,
},
body
:
JSON
.
stringify
({
bearer_token
:
token
,
}),
});
this
.
$router
.
push
(
'
/
'
);
...
...
pages/index.vue
View file @
817ac51e
...
...
@@ -82,8 +82,8 @@ export default {
};
},
methods
:
{
login
()
{
fetch
(
"
http://127.0.0.1:8000/api/login
"
,
{
async
login
()
{
var
resp
=
await
fetch
(
"
http://127.0.0.1:8000/api/login
"
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
...
...
@@ -92,8 +92,20 @@ export default {
email
:
this
.
email
,
password
:
this
.
password
,
}),
});
}).
then
((
response
)
=>
{
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