notifFunction.js 767 B

123456789101112131415161718192021222324252627282930313233
  1. const axios = require('../utils/axios')
  2. const kontakModel = require('../model/kontak.model')
  3. exports.notifWA = async (templateId, data, where = {}) => {
  4. const kontak = await kontakModel.find(where)
  5. const contacts = kontak.map((e) => ({ name: e.nama, number: e.no_hp }))
  6. const send = await axios.post(
  7. 'https://api.kemdikbud.go.id:8243/qontak/1.0/send',
  8. {
  9. templateId,
  10. contacts,
  11. body: data,
  12. }
  13. )
  14. return send
  15. }
  16. exports.notifWA2 = async (templateId, { nama, no_hp }, data) => {
  17. const send = await axios.post(
  18. 'https://api.kemdikbud.go.id:8243/qontak/1.0/send',
  19. {
  20. templateId,
  21. contacts: [
  22. {
  23. name: nama,
  24. number: no_hp,
  25. },
  26. ],
  27. body: data,
  28. }
  29. )
  30. return send
  31. }