Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2020
PPL-C
Diskominfo-D'Blood
Mantan Aab-D Blood
Commits
a9224699
Commit
a9224699
authored
Apr 07, 2020
by
Nabila Febri Viola
Browse files
[REFACTOR] Changes fetch to axios
parent
2b3cfb5f
Changes
2
Hide whitespace changes
Inline
Side-by-side
frontend/src/api.js
View file @
a9224699
...
...
@@ -26,18 +26,3 @@ export const postUserLogout = () =>
detail
:
"
SUCCESS
"
,
},
})
export
const
postRegisterUser
=
async
()
=>
await
fetch
(
`
${
BASE_API_URL
}
/auth/register-full/`
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
},
body
:
data
,
})
.
then
(
async
response
=>
{
return
await
response
.
json
()
})
.
then
(
async
data
=>
{
return
data
})
frontend/src/components/modal-register.js
View file @
a9224699
...
...
@@ -2,6 +2,7 @@ import React from "react"
import
{
Form
}
from
"
react-bootstrap
"
import
{
useForm
}
from
"
react-hook-form
"
import
*
as
yup
from
"
yup
"
import
axios
from
"
axios
"
import
{
BASE_API_URL
}
from
"
../config
"
import
ModalRegisterAccount
from
"
./register-account
"
...
...
@@ -68,35 +69,28 @@ const ModalRegister = ({ show, handleClose }) => {
validationSchema
:
schema
,
})
const
onSubmit
=
async
data
=>
{
data
=
'
{"email": "
'
+
data
.
email
+
'
", "password": "
'
+
data
.
password
+
'
", "first_name": "
'
+
data
.
first_name
+
'
", "profile":
'
+
JSON
.
stringify
(
data
)
+
"
}
"
await
fetch
(
`
${
BASE_API_URL
}
/auth/register-full/`
,
{
method
:
"
POST
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
,
await
axios
({
method
:
"
post
"
,
url
:
`
${
BASE_API_URL
}
/auth/register-full/`
,
// url: "https://dblood-staging.netlify.app/auth/register-full/",
timeout
:
60000
,
data
:
{
email
:
data
.
email
,
password
:
data
.
password
,
first_name
:
data
.
first_name
,
profile
:
data
,
},
body
:
data
,
})
.
then
(
async
response
=>
{
return
await
response
.
json
()
})
.
then
(
async
data
=>
{
await
window
.
alert
(
"
Silakan verifikasi email terlebih dahulu di
"
+
data
.
email
+
.
then
(
response
=>
{
console
.
log
(
response
.
data
)
window
.
alert
(
"
Silakan verifikasi email terlebih dahulu di
"
+
response
.
data
.
email
+
"
untuk login.
"
),
await
location
.
reload
()
location
.
reload
()
})
.
catch
(
error
=>
console
.
error
(
"
timeout exceeded
"
))
}
return
(
<>
...
...
Write
Preview
Supports
Markdown
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