UNPKG

@trivia-api/fetch

Version:

Functions to fetch data from The Trivia API.

32 lines (31 loc) 1.52 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getQuestionById = void 0; const client_1 = require("@trivia-api/client"); const constants_1 = require("./constants"); const utils_1 = require("./utils"); /** * Get a question by its ID * @param params * @param params.id - ID of the question to get * @param params.apiKey - API key to use for the request * @param params.language - Language to receive the question in. Defaults to English. */ const getQuestionById = ({ apiKey, id, language }, host = constants_1.TRIVIA_API_BASE_URL) => __awaiter(void 0, void 0, void 0, function* () { (0, utils_1.setHeaders)({ apiKey }); (0, utils_1.setHost)(host); return client_1.QuestionsService.getQuestionById({ id, language, }); }); exports.getQuestionById = getQuestionById;