Add gitignore and fixes

This commit is contained in:
Guillermo Bonet 2022-06-22 13:51:49 +02:00
parent 0c4a47ee95
commit 46995c0bb2
2 changed files with 18 additions and 7 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

14
main.js
View File

@ -134,13 +134,17 @@ async function main(){
const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64'); const credentials = `Basic ` + Buffer.from(`${user}:${passw}`).toString('base64');
let response = await fetch(urlOrganizations, { try {
var response = await fetch(urlOrganizations, {
method: "GET", method: "GET",
headers: { headers: {
Authorization: credentials Authorization: credentials
} }
}); });
} catch (notfound) {
console.error(`${error}Server '${config.grafanaUrl}' not found`.red);
process.exit(1);
};
let AllOrganizations = await response.json(); let AllOrganizations = await response.json();
if (AllOrganizations.message==='invalid username or password') { if (AllOrganizations.message==='invalid username or password') {
@ -262,6 +266,12 @@ async function main(){
console.log(colors.green.bold(`-------- Have been found ${numberOfObjects} results in ${totalDashboards} dashboards -------\n`)); console.log(colors.green.bold(`-------- Have been found ${numberOfObjects} results in ${totalDashboards} dashboards -------\n`));
if (!response) {
console.log(`${error}The server don't exists`);
process.exit(1);
}
process.exit(); process.exit();
} }
main(); main();