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
63274c7a
Commit
63274c7a
authored
Feb 06, 2023
by
TTS Kieu Tuan Anh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
axios login
parent
9a6040a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
27 deletions
+23
-27
login.vue
pages/login.vue
+23
-27
No files found.
pages/login.vue
View file @
63274c7a
...
@@ -109,41 +109,37 @@ export default {
...
@@ -109,41 +109,37 @@ export default {
this
.
password
=
''
this
.
password
=
''
this
.
checkbox
=
false
this
.
checkbox
=
false
},
},
async
login
()
{
async
login
()
{
try
{
try
{
const
resp
=
await
fetch
(
'
http://127.0.0.1:8000/api/login
'
,
{
const
resp
=
await
this
.
$axios
.
post
(
'
/login
'
,
method
:
'
POST
'
,
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Accept
:
'
application/json
'
},
body
:
JSON
.
stringify
({
email
:
this
.
email
,
email
:
this
.
email
,
password
:
this
.
password
,
password
:
this
.
password
,
status
:
this
.
status
status
:
this
.
status
,
})
},
}).
then
((
response
)
=>
{
{
return
response
.
json
()
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
Accept
:
'
application/json
'
,
}
})
})
console
.
log
(
resp
.
status
)
localStorage
.
setItem
(
"
token
"
,
resp
.
data
.
data
.
bearer_token
)
localStorage
.
setItem
(
'
token
'
,
'
Bearer
'
+
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
"
token
"
,
resp
.
data
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
'
token
'
,
'
Bearer
'
+
resp
.
data
.
bearer_token
)
this
.
$auth
.
$storage
.
setUniversal
(
"
userName
"
,
resp
.
data
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
'
userName
'
,
resp
.
data
.
name
)
this
.
$auth
.
$storage
.
setUniversal
(
"
loggedIn
"
,
"
true
"
)
this
.
$auth
.
$storage
.
setUniversal
(
'
loggedIn
'
,
'
true
'
)
if
(
resp
.
status
==
"
200
"
)
{
if
(
resp
.
status
==
'
success
'
)
{
this
.
$toast
.
success
(
"
Successfully authenticated
"
,
{
this
.
$toast
.
success
(
'
Successfully authenticated
'
,
{
duration
:
2000
,
duration
:
2000
});
})
this
.
$router
.
push
(
"
home
"
);
this
.
$router
.
push
(
'
home
'
)
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
$toast
.
error
(
'
Username or Password not valid
'
,
{
this
.
$toast
.
error
(
"
Username or Password not valid
"
,
{
duration
:
2000
duration
:
2000
,
})
})
;
this
.
$router
.
push
(
'
/login
'
)
this
.
$router
.
push
(
"
/login
"
);
}
}
}
}
}
}
}
</
script
>
</
script
>
<
style
scoped
>
<
style
scoped
>
...
...
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