I've got a variable id inside a function
How can I return the variabe id outside of the function
public async info(version,login,password) {
const options = {
method: "GET",
url: "**",
headers: {
Accept: "application/json",
Authorization: "*"
},
};
request(options, function(error, response, issue) {
if (error) throw new Error(error);
console.log("Response: " + response.statusCode + " " + response.statusMessage);
const json = JSON.parse(issue);
for (let i = 0; i < json.versions.length; i++) {
const test = json.versions[i].name;
if (test === version) {
const id = json.versions[i].id; // want to return this value
}
}
});
return this.doTest(id, login, password); // didn't know what is id here
}
Thanks for your help