throw error if required secrets have not been added

This commit is contained in:
Viet Huynh
2023-09-29 06:51:13 +07:00
parent e4f44e3e2b
commit af24c152a8
+6
View File
@@ -20,6 +20,12 @@ if (!globalThis.fetch) {
* @returns {Promise}
*/
const request = async (url, options) => {
if (!API_TOKEN || !ACCOUNT_ID || !ACCOUNT_EMAIL) {
throw new Error(
"One or more required secrets have not been added: CLOUDFLARE_API_KEY, CLOUDFLARE_ACCOUNT_ID, and CLOUDFLARE_ACCOUNT_EMAIL"
);
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${API_TOKEN}`,