Advertisement
asdfasdfaefasd234

Untitled

Aug 19th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. loginA: (user_obj) => {
  2. console.log('login2 is running...');
  3.  
  4. const Promise = require('bluebird');
  5. const Async = require('simplify-async').simpleAsync;
  6. var request = require('request');
  7. var request = request.defaults({jar: true, headers: eo.config.headers});
  8.  
  9. const formData = {
  10. username: user_obj.username,
  11. password: user_obj.password,
  12. grant_type: 'password'
  13. };
  14.  
  15. const options = {
  16. url: eo.config.baseUrl + 'token',
  17. form: formData,
  18. referer: eo.config.baseUrl,
  19. };
  20.  
  21.  
  22. // We look in here
  23. const eo_login = (options) => {
  24. // console.log('the function is running', options);
  25. request.post(options, foo);
  26. // console.log('making post request with options:', options);
  27. };
  28.  
  29. eo_login(options);
  30.  
  31.  
  32.  
  33.  
  34. const foo = (err, res, body) => {
  35. console.log('FOO GOT TRIGGERED!');
  36. if (err) {console.log(err, 'FAILED'); return}
  37.  
  38. const info = JSON.parse(body);
  39. console.log();
  40. // console.log(info);
  41. console.log();
  42. console.log('Succesfully logged in');
  43. console.log();
  44.  
  45.  
  46. const getBalance = () => {
  47. console.log('WE AR ENOW IN GET BALANCE');
  48. const promise = new Async();
  49.  
  50. request.get({url: 'https://www.eovendo.com/api/Profile/GetUserStatus'}, (err, res, body) => {
  51. if (err) promise.reject(err);
  52. const balance = JSON.parse(body);
  53. console.log('>>>', balance);
  54. promise.resolve(balance)
  55. });
  56. return promise.promise;
  57. };
  58.  
  59. getBalance()
  60. .catch(err => console.log(err))
  61. .then(res => {
  62. console.log('balance func response, msg:', res)
  63. });
  64. };
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement