const got = require('got'); const isProduction = require('vn-loopback/server/boot/isProduction'); const {models} = require('vn-loopback/server/server'); module.exports = async(destination, message) => { const smsConfig = await models.SmsConfig.findOne(); const params = { api_key: smsConfig.apiKey, messages: [{ from: smsConfig.title, to: destination, text: message }] }; let response; try { if (!isProduction(false)) response = {result: [{status: 'ok'}]}; else { const jsonTest = { json: params }; response = await got.post(smsConfig.uri, jsonTest).json(); } } catch (e) { response = e; } return response; };