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:
@@ -0,0 +1,30 @@
|
||||
import { API_BASE_URL } from '../constants/api';
|
||||
|
||||
export const messageEventResponseApi = {
|
||||
getMessageEventResponsesByUserId: async (userId, authBearerToken) => {
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/api/v1/schedule/message/event/response?user_id=${userId}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authBearerToken,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 401) {
|
||||
throw new Error('Session expired. Please log in again.');
|
||||
} else if (response.status === 404) {
|
||||
console.log('No message event responses associated with user');
|
||||
// setLoading(false);
|
||||
return;
|
||||
} else {
|
||||
throw new Error(`Failed to fetch sent messages: ${response.status}`);
|
||||
}
|
||||
} else {
|
||||
return response.json();
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user