Browse Source

Added user registration call

pull/1886/head
Gabe Kangas 4 years ago
parent
commit
35546c0c6d
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA
  1. 29
      web/services/UserService.ts

29
web/services/UserService.ts

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
const URL_CHAT_REGISTRATION = `http://localhost:8080/api/chat/register`;
interface UserRegistrationResponse {
id: string;
accessToken: string;
displayName: string;
}
class UserService {
registerUser(username: string): Promise<UserRegistrationResponse> {
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ displayName: username }),
};
try {
const response = await fetch(URL_CHAT_REGISTRATION, options);
const result = await response.json();
return result;
} catch (e) {
console.error(e);
}
return null;
}
}
Loading…
Cancel
Save