1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
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; //here id
}
}
});
console.log(id); // I need to retrieve the const id here but id it's undefined, so how can I specified id
} |
Partager