Created
November 25, 2022 14:00
-
-
Save reegodev/74a987c85390ca8bc64b2bafb294a3a5 to your computer and use it in GitHub Desktop.
Trigger too many connections error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
const APP_URL = 'https://meek-forgetful-play-dnk3e.ondigitalocean.app'; | |
const TOKEN = 'eyJhbGciOiJ...'; | |
const sendRequest = async (endpoint) => { | |
try { | |
await axios.get(`${APP_URL}${endpoint}`, { | |
headers: { | |
authorization: `Bearer ${TOKEN}`, | |
}, | |
}); | |
} catch (e) { | |
if (e.response) { | |
console.log(e.response.status); | |
} else { | |
console.log(e); | |
} | |
} | |
}; | |
const endpoints = [ | |
'/content-type-builder/content-types', | |
'/content-type-builder/reserved-names', | |
'/content-type-builder/components', | |
'/admin/users/me', | |
'/admin/users/me/permissions', | |
]; | |
const fetchEndpoints = () => { | |
return Promise.all(endpoints.map((endpoint) => sendRequest(endpoint))); | |
}; | |
setInterval(async () => { | |
console.log('fetching'); | |
await fetchEndpoints(); | |
console.log('done fetching'); | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment