@trivia-api/fetch
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -20,2 +20,2 @@ import { Question } from "../../models/src"; | ||
*/ | ||
export declare const getQuestions: (params?: GetQuestionsParams, host?: string) => Promise<Question[]>; | ||
export declare const getQuestions: (params?: GetQuestionsParams, key?: string | null, host?: string) => Promise<Question[]>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -48,10 +59,14 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
*/ | ||
var getQuestions = function (params, host) { | ||
var getQuestions = function (params, key, host) { | ||
if (params === void 0) { params = {}; } | ||
if (host === void 0) { host = constants_1.TRIVIA_API_BASE_URL; } | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var queryString, response; | ||
var _headers, queryString, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_headers = __assign({}, constants_1.headers); | ||
if (key) { | ||
_headers["x-api-key"] = key; | ||
} | ||
queryString = params && Object.keys(params).length | ||
@@ -74,3 +89,3 @@ ? Object.entries(params).reduce(function (prev, _a, i) { | ||
: ""; | ||
return [4 /*yield*/, axios_1["default"].get("".concat(host, "/api/questions").concat(queryString))]; | ||
return [4 /*yield*/, axios_1["default"].get("".concat(host, "/api/questions").concat(queryString), { headers: _headers })]; | ||
case 1: | ||
@@ -77,0 +92,0 @@ response = _a.sent(); |
{ | ||
"name": "@trivia-api/fetch", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "Functions to fetch data from The Trivia API.", | ||
@@ -13,3 +13,3 @@ "keywords": [ | ||
], | ||
"main": "dist/index.js", | ||
"main": "dist/fetch/src/index.js", | ||
"scripts": { | ||
@@ -16,0 +16,0 @@ "test": "jest", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42061
833