daily pastebin goal
6%
SHARE
TWEET

Untitled

a guest Oct 15th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios')
  2. const publicIp = require('public-ip');
  3. const localip = require('local-ip');
  4.  
  5. const _this = this;
  6.  
  7.  
  8. const registerPartner = () => {
  9.     /* const dataToSend = {
  10.         id_cliente: 1,
  11.         ip: `${getLocalIP()}, ${getPublicIP()}`, //"10.211.55.2"
  12.     }; */
  13.  
  14.     const dataToSend = {
  15.         id_cliente: 6,
  16.         ip: "10.211.55.2"
  17.     }
  18.     axios.post('http://pedravirada.ddns.net:8081/zealplus/srv_registra_cliente/', { dataToSend })
  19.       .then((res) => {
  20.         console.log('registerPartner', res.data);
  21.          //console.log('PublicIP', getPublicIP());
  22.          
  23.         return res.data
  24.       })
  25.       .catch((error) => {
  26.         console.log(error);
  27.       });
  28.   };
  29.  
  30.   const getPublicIP = () => {
  31.     publicIp.v4().then(ip => {
  32.         console.log(ip);
  33.         //=> '46.5.21.123'
  34.         return ip;
  35.     });
  36.   };
  37.  
  38.   //var iface = 'wlan0';
  39.  
  40.   const getLocalIP = () => {
  41.     localip('wlan0', (err, res) => {
  42.         if (err) {
  43.           throw new Error('I have no idea what my local ip is.');
  44.         }
  45.         console.log('My local ip address on ' + iface + ' is ' + res);
  46.       });
  47.   };
  48.  
  49. module.exports = {registerPartner};
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top