-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
114 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import SERVICE_API_URL from "./ServiceEndPoint"; | ||
const BASE_URL = SERVICE_API_URL.BASE_URL; | ||
|
||
export class RegisterService { | ||
static async register(data: { | ||
redirectUrl?: string; | ||
email: string; | ||
password: string; | ||
name: string; | ||
birthDate: string; | ||
pin: string; | ||
}): Promise<void> { | ||
const deviceToken = window.nanu_androidgw?.devicetoken || "WEB_NONE"; | ||
const requestBody = { | ||
deviceToken: deviceToken, | ||
pin: data.pin, | ||
password: data.password, | ||
name: data.name, | ||
email: data.email, | ||
birthDate: data.birthDate, | ||
}; | ||
|
||
const endpoint = `${BASE_URL}/auth/register`; | ||
|
||
const response = await fetch(endpoint, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(requestBody), | ||
mode: "cors", | ||
}); | ||
|
||
const result = await response.json(); | ||
|
||
if (!response.ok) { | ||
throw new Error(result.message || "회원가입 중 오류가 발생했습니다."); | ||
} | ||
|
||
if (data.redirectUrl) { | ||
window.location.href = data.redirectUrl; | ||
} else { | ||
window.location.href = "/home"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
declare global { | ||
interface Window { | ||
nanu_androidgw?: { | ||
devicetoken?: string; | ||
}; | ||
} | ||
} |