push messages to telegram from contactUs form
This commit is contained in:
@@ -9,21 +9,24 @@ export const sendMessage = async (data: TelegramMessage) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const body = JSON.stringify({
|
||||
source: data.source,
|
||||
name: data.name,
|
||||
phone_number: data.phone_number,
|
||||
message: data.message,
|
||||
})
|
||||
|
||||
const response = await fetch(`${API_URL}/send-message/`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: JSON.stringify({
|
||||
source: data.source,
|
||||
name: data.name,
|
||||
phone_number: data.phone_number,
|
||||
message: data.message,
|
||||
}),
|
||||
body,
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
let errorMessage = `Failed to send form data: ${response.status} ${response.statusText}`
|
||||
try {
|
||||
const errorData = await response.text()
|
||||
|
||||
if (errorData) {
|
||||
errorMessage += ` - ${errorData}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user