Closes #6 Reviewed-on: phoenix/textsender#22 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
23 lines
491 B
JavaScript
23 lines
491 B
JavaScript
import { AUTH_API_BASE_URL } from '../constants/api';
|
|
|
|
export class LoginRequest {
|
|
username = '';
|
|
password = '';
|
|
}
|
|
|
|
export const loginApi = {
|
|
login: async (request) => {
|
|
const reponse = await fetch(`${AUTH_API_BASE_URL}/api/v1/login`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(request),
|
|
});
|
|
|
|
if (reponse.ok) {
|
|
return reponse.json();
|
|
} else {
|
|
throw new Error('Error logging in');
|
|
}
|
|
},
|
|
};
|