mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Added user registration call
This commit is contained in:
parent
15ca73a438
commit
35546c0c6d
29
web/services/UserService.ts
Normal file
29
web/services/UserService.ts
Normal file
@ -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…
x
Reference in New Issue
Block a user