Guest User

Untitled

a guest
May 21st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. function authorisationFilemaker(filemakerToken) {
  2. //Авторизация
  3. var postPrepare = { layout: "vibroTable", password: "admin", user: "admin"};
  4. var options = {
  5. "rejectUnauthorized": false,
  6. // strictSSL: false,
  7. url: 'https://10.0.1.10/fmi/rest/api/auth/workShopData',
  8. method: "POST",
  9. headers: {'Content-Type': 'application/json'},
  10. body: JSON.stringify(postPrepare)
  11. };
  12.  
  13.  
  14. requestHTTPS(options, (error, response, body) => {
  15. console.log('error:', error); // Print the error if one occurred
  16. console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  17. console.log('body:', body); // Print the HTML for the Google homepage.
  18. var tokenJSON = JSON.parse(body);
  19. filemakerToken = tokenJSON.token;
  20. // filemakerToken = querystring.parse(requestResult);
  21. setResult(filemakerToken);
  22. // console.log('JSON:', tokenJSON);
  23. console.log('filemakerToken get from request:', filemakerToken);
  24. });
  25. // console.log('must be new token: ', filemakerToken);
  26. }
  27.  
  28. const Promise = require('bluebird');
  29.  
  30.  
  31. Promise.resolve(/*Здесь передаете параметры*/)
  32. .then(onRequest(/*Так же и здесь передаете параметры*/)) // P.S. Делайте функции верно, каждая функция должна что-то возвращать. **return smthng;**
  33. .catch(err => {if (err) throw new Error(err)})
  34. .then(value => {authorisationFilemaker(/*Здесь можно использовать значение, которое возвращает Ваша функция onRequest*/)})
  35. .catch(err => {if (err) trow new Error(err)})
  36. .then(value => {console.log(value)});
Add Comment
Please, Sign In to add comment