mirror of
https://github.com/Nezumi-2711/cloudflare-gateway-pihole-scripts.git
synced 2026-09-22 13:38:37 +00:00
handle API error
This commit is contained in:
+6
-2
@@ -63,8 +63,12 @@ const createZeroTrustListsAtOnce = async (items) => {
|
|||||||
listNumber++;
|
listNumber++;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(requests);
|
try {
|
||||||
console.log(`Created ${totalListNumber} lists`);
|
await Promise.all(requests);
|
||||||
|
console.log(`Created ${totalListNumber} lists`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error occurred while creating lists - ${err.toString()}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ const request = async (url, options) => {
|
|||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user