Skip to content

Commit

Permalink
fix: wait between api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
gbicou committed Feb 15, 2024
1 parent 7fff14c commit 1ad6c97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-rabbits-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bicou/directus-extension-imagga": patch
---

wait between api calls
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export default defineHook(({ action }, { services, logger }) => {
// retrieve colors
let colors: object | undefined;
if (IMAGGA_COLORS_ENABLE) {
// wait 1 second to avoid rate limiting
if (IMAGGA_TAGS_ENABLE) await new Promise((resolve) => setTimeout(resolve, 1000));

// imagga api call
const response = await axios.get<ColorsResponse>(IMAGGA_API + "/colors", {
params: {
image_upload_id: upload_id,
Expand Down

0 comments on commit 1ad6c97

Please sign in to comment.