tsk-6: Send Message (#22)

Closes #6

Reviewed-on: phoenix/textsender#22
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2026-01-04 00:21:22 +00:00
committed by phoenix
parent a1a8b44da3
commit 34644d1cd2
24 changed files with 1690 additions and 146 deletions
+29
View File
@@ -0,0 +1,29 @@
import { API_BASE_URL } from '../constants/api';
export class CreateMessageRequest {
content = '';
user_id = '';
}
export const messageApi = {
createMessage: async (requestBody, authBearerToken) => {
const response = await fetch(`${API_BASE_URL}/api/v1/message/new`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: authBearerToken,
},
body: JSON.stringify(requestBody),
});
if (!response.ok) {
if (response.status === 500) {
throw new Error('Something went wrong with the system');
} else {
throw new Error('Failed to create message');
}
} else {
return response.json();
}
},
};