SHARE
TWEET

Untitled

a guest Feb 14th, 2020 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios');
  2.  
  3. const USERNAME = 'riccardo.tasso@celi.it';
  4. const PASSWORD = 'c3kks3hf';
  5.  
  6. const login_options = {
  7.     url: 'https://wallet.h-farm.com/api/users/sign_in',
  8.     method: 'post',
  9.     //forever: true,
  10.     params: {
  11.         'username': USERNAME,
  12.         'password': PASSWORD
  13.     },
  14.     headers: {
  15.         "Accept": "application/vnd.beacon.v3+json",
  16.         "Client-Version": "Web/1.1",
  17.         "Accept-Language": "it",
  18.         "If-Modified-Since": "",
  19.         "If-None-Match": "",
  20.         "Content-Type": "application/x-www-form-urlencoded"
  21.     }
  22. };
  23.  
  24.  
  25.  
  26. function signin() {
  27.     console.log("BEGIN signin");
  28.     try {
  29.         return axios(login_options);
  30.     } catch (error) {
  31.         console.log("ERROR signin");
  32.         console.error(error.toJSON());
  33.     }
  34.  
  35.     console.log("END signin");
  36. }
  37.  
  38.  
  39.  
  40. async function startups() {
  41.     try {
  42.         console.log("BEGIN startups");
  43.         var user_signin = await signin();
  44.         //console.log(login);
  45.  
  46.         var token = user_signin['data']['user']['authentication_token'];
  47.         var username = user_signin['data']['user']['username'];
  48.  
  49.         var startups_options = {
  50.             url: 'https://wallet.h-farm.com/api/startups',
  51.             method: 'get',
  52.             //forever: true,
  53.             headers: {
  54.                 "Accept": "application/vnd.beacon.v3+json",
  55.                 //"User-Agent": "curl/7.47.0",
  56.                 "Client-Version": "Web/1.1",
  57.                 "Accept-Language": "it",
  58.                 "X-API-Username": username,
  59.                 "X-API-Token": token,
  60.                 "If-Modified-Since": "",
  61.                 "If-None-Match": ""
  62.             }
  63.         };
  64.  
  65.         const response = await axios(startups_options);
  66.         console.log(response);
  67.  
  68.     } catch (error) {
  69.         console.log("ERROR startups");
  70.         console.error(error);
  71.     }
  72.  
  73.     console.log("END startups");
  74.  
  75. }
  76.  
  77. console.log("Hello world");
  78.  
  79. (async () => {
  80.     await startups();
  81. })();
  82.  
  83.  
  84. console.log("Goodbye world");
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