fixing notification wa
This commit is contained in:
@@ -46,6 +46,7 @@ const getNotificationByIdDb = async (id) => {
|
||||
const getDeviceNotificationByIdDb = async (chanel_id) => {
|
||||
const queryText = `
|
||||
SELECT
|
||||
brand_id,
|
||||
device_code,
|
||||
device_name,
|
||||
device_location,
|
||||
|
||||
@@ -24,7 +24,7 @@ const shortUrltiny = async (encodedToken) => {
|
||||
|
||||
const encodedUrl = encodeURIComponent(url); // ⬅️ Encode dulu!
|
||||
|
||||
const response = await axios.get(`https://tinyurl.com/api-create.php?url=${encodedUrl}`,{httpsAgent}) ;
|
||||
const response = await axios.get(`https://tinyurl.com/api-create.php?url=${encodedUrl}`, { httpsAgent });
|
||||
|
||||
let shortUrl = response.data;
|
||||
if (!shortUrl.startsWith('http')) {
|
||||
@@ -45,14 +45,23 @@ const sendNotifikasi = async (phone, message) => {
|
||||
const endPointWhatsapp = process.env.ENDPOINT_WHATSAPP;
|
||||
|
||||
try {
|
||||
const response = await axios.post(endPointWhatsapp, payload,{httpsAgent} );
|
||||
// console.log(response.data);
|
||||
return response?.data
|
||||
const response = await axios.post(endPointWhatsapp, payload, { httpsAgent });
|
||||
|
||||
return {
|
||||
success: true,
|
||||
statusCode: response.status, // 200, 201, dll
|
||||
data: response.data
|
||||
};
|
||||
} catch (error) {
|
||||
// console.error(error.response?.data || error.message);
|
||||
return error.response?.data || error.message
|
||||
return {
|
||||
success: false,
|
||||
statusCode: error.response?.status || null,
|
||||
errorCode: error.code || null, // ECONNABORTED, dll
|
||||
message: error.response?.data || error.message
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user