@trivia-api/fetch
Version:
Functions to fetch data from The Trivia API.
29 lines (28 loc) • 1.41 kB
JavaScript
;
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.reportQuestion = void 0;
const client_1 = require("@trivia-api/client");
const constants_1 = require("./constants");
const utils_1 = require("./utils");
/**
* Report a question, marking it as incorrect or inappropriate
*/
const reportQuestion = ({ apiKey, questionId, reason }, 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);
const response = yield client_1.QuestionsService.reportQuestion({
requestBody: { reason },
id: questionId,
});
return response;
});
exports.reportQuestion = reportQuestion;