Skip to content

Commit

Permalink
add delay to trivia api call to fix api call limit
Browse files Browse the repository at this point in the history
  • Loading branch information
petersem committed Nov 29, 2023
1 parent 0ca38c5 commit 0900ed3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions classes/custom/trivia.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const util = require('util');
const axios = require("axios");
const { CardTypeEnum } = require("../cards/CardType");
const { triviaCategories } = require("../../consts");

const delay = time => new Promise(res=>setTimeout(res,time));
/**
* @desc Used to get a list of custom pictures
*/
Expand Down Expand Up @@ -60,7 +60,6 @@ class Trivia {
"&category=" +
category +
apiToken)


response = await axios
.get(
Expand Down Expand Up @@ -127,6 +126,7 @@ class Trivia {
// get questions for specific category
await categories.reduce(async (memo, md) => {
await memo;

let trivSet = await this.GetQuestions(hasThemes, hasArt, numberOfQuestions, md, token);
if(trivSet.length !== 0) {
allTrivCards = allTrivCards.concat(trivSet);
Expand Down Expand Up @@ -154,6 +154,7 @@ class Trivia {

// get questions for specific category

await delay(5000);
const raw = await this.GetRawData(numberOfQuestions,questionCategory, hasThemes, token);


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posterr",
"version": "1.17.0",
"version": "1.16.4",
"description": "A digital display for your media",
"main": "index.js",
"bin": "index.js",
Expand Down

0 comments on commit 0900ed3

Please sign in to comment.