Closes #6 Reviewed-on: phoenix/textsender#22 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
25 lines
577 B
JavaScript
25 lines
577 B
JavaScript
import { AUTH_API_BASE_URL } from '../constants/api';
|
|
|
|
export class RegisterRequest {
|
|
phone_number = '';
|
|
firstname = '';
|
|
password = '';
|
|
}
|
|
|
|
export const registerApi = {
|
|
registerUser: async (request) => {
|
|
const response = await fetch(`${AUTH_API_BASE_URL}/api/v1/register`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(request),
|
|
});
|
|
|
|
if (response.ok) {
|
|
return response.json();
|
|
} else {
|
|
console.error('Error registering');
|
|
throw new Error('Registration failed');
|
|
}
|
|
},
|
|
};
|