Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function authorisationFilemaker(filemakerToken) {
- //Авторизация
- var postPrepare = { layout: "vibroTable", password: "admin", user: "admin"};
- var options = {
- "rejectUnauthorized": false,
- // strictSSL: false,
- url: 'https://10.0.1.10/fmi/rest/api/auth/workShopData',
- method: "POST",
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(postPrepare)
- };
- requestHTTPS(options, (error, response, body) => {
- console.log('error:', error); // Print the error if one occurred
- console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
- console.log('body:', body); // Print the HTML for the Google homepage.
- var tokenJSON = JSON.parse(body);
- filemakerToken = tokenJSON.token;
- // filemakerToken = querystring.parse(requestResult);
- setResult(filemakerToken);
- // console.log('JSON:', tokenJSON);
- console.log('filemakerToken get from request:', filemakerToken);
- });
- // console.log('must be new token: ', filemakerToken);
- }
- const Promise = require('bluebird');
- Promise.resolve(/*Здесь передаете параметры*/)
- .then(onRequest(/*Так же и здесь передаете параметры*/)) // P.S. Делайте функции верно, каждая функция должна что-то возвращать. **return smthng;**
- .catch(err => {if (err) throw new Error(err)})
- .then(value => {authorisationFilemaker(/*Здесь можно использовать значение, которое возвращает Ваша функция onRequest*/)})
- .catch(err => {if (err) trow new Error(err)})
- .then(value => {console.log(value)});
Add Comment
Please, Sign In to add comment