Check Array or string for multiple email sendGridmaster
| @@ -29,6 +29,15 @@ amqp.connect(process.env.AMQP_SERVER).then(async conn => { | |||||
| }).catch(console.warn) | }).catch(console.warn) | ||||
| function sendReceipt(message) { | function sendReceipt(message) { | ||||
| try { | |||||
| const parsedData = JSON.parse(message.email); | |||||
| if (Array.isArray(parsedData)) { | |||||
| message.email = parsedData | |||||
| } | |||||
| } catch (error) { | |||||
| console.log("Data bukan dalam format JSON."); | |||||
| } | |||||
| const now = new Date() | const now = new Date() | ||||
| const msg = { | const msg = { | ||||
| to: message.email, | to: message.email, | ||||
| @@ -29,6 +29,15 @@ amqp.connect(process.env.AMQP_SERVER).then(async conn => { | |||||
| }).catch(console.warn) | }).catch(console.warn) | ||||
| function sendReceipt(message) { | function sendReceipt(message) { | ||||
| try { | |||||
| const parsedData = JSON.parse(message.email); | |||||
| if (Array.isArray(parsedData)) { | |||||
| message.email = parsedData | |||||
| } | |||||
| } catch (error) { | |||||
| console.log("Data bukan dalam format JSON."); | |||||
| } | |||||
| const now = new Date() | const now = new Date() | ||||
| const msg = { | const msg = { | ||||
| to: message.email, | to: message.email, | ||||