tsk-7: Schedule message #8
@@ -0,0 +1,35 @@
|
||||
import { API_BASE_URL } from '../constants/api';
|
||||
|
||||
export const scheduleApi = {
|
||||
scheduleMessage: async (s, authBearerToken) => {
|
||||
console.log('Scheduling message');
|
||||
const reqBody = {
|
||||
scheduled: s.scheduedTime.toISOString(),
|
||||
status: s.status,
|
||||
user_id: s.userId,
|
||||
};
|
||||
|
||||
console.log(`Request body: ${reqBody}`);
|
||||
const response = await fetch(`${API_BASE_URL}/api/v1/schedule/message`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: authBearerToken,
|
||||
},
|
||||
body: JSON.stringify(reqBody)
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Error scheduling message');
|
||||
} else {
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* "scheduled": "{{scheduling_time}}",
|
||||
"status": "{{status_pending}}",
|
||||
"user_id": "{{user_id}}"
|
||||
*/
|
||||
Reference in New Issue
Block a user