Skip to content

Commit eb26d34

Browse files
committed
feat(user-signup): [next-ts-middle-out] 🟢 add signUpUser fetch implementation
1 parent 01c1a5f commit eb26d34

File tree

1 file changed

+13
-2
lines changed
  • exercises/user_signup/solutions/codely_next-typescript-middle-out/src/services

1 file changed

+13
-2
lines changed
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
export async function signUpUser({name, email}: {name: string, email: string}): Promise<void> {
2-
return;
1+
export async function signUpUser(userData: {name: string, email: string}): Promise<void> {
2+
await fetch("/api/signup", {
3+
method: "POST",
4+
body: JSON.stringify(userData),
5+
headers: {
6+
"Content-Type": "application/json",
7+
},
8+
})
9+
.then(response => {
10+
if (response.status !== 200) {
11+
throw new Error()
12+
}
13+
})
314
}

0 commit comments

Comments
 (0)