I have a file (function.js) with a function. I have a another file where I want to call this function
My problem is that i'm trying to call a variable inside this function but I don't know how can I ?
Function.js
function getAllIssueForSCII(){
var options = {
method: 'GET',
url: 'https://***.atlassian.net/rest/api/3/search?jql=project=SCII',
headers: {
'Accept': 'application/json',
'Authorization': "Basic ***"
}
};
return new Promise(function (resolve) {
request(options, function (error, response, data) {
if (!error && response.statusCode === 200) {
console.log('JIRA login success!!')
var json = JSON.parse(data); /!\ Call this variable
} else {
console.log('error: ' + response.statusCode + ': ' + data.statusMessage)
}
})
})
}
module.exports.getAllIssueForSCII = getAllIssueForSCII;
Index.js
var functions = require('./functions.js')
functions.getAllIssueForSCII();
console.log(json) // Error;
Thanks in advance for your help :)