Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brecert/trivia-deno

simple deno module and cli to interact with OpenTDB
https://github.com/brecert/trivia-deno

Last synced: 3 days ago
JSON representation

simple deno module and cli to interact with OpenTDB

Awesome Lists containing this project

README

        

# Trivia

![@brecert/trivia](https://img.shields.io/npm/v/@brecert/trivia) [![deno module](https://shield.deno.dev/x/trivia_deno)](https://shield.deno.dev/x/trivia_deno)

This package contains a typed fetch builder and some utils for working with the [OpenTDB](https://opentdb.com/) api.

# Usage

You can find more info in the [documentation](https://doc.deno.land/https://deno.land/x/trivia_deno/trivia.ts).

```ts
import {
Encoding,
triviaFetch,
decodeQuestion,
} from "https://deno.land/x/trivia_deno/trivia.ts";

const questions = await triviaFetch({
amount: 5,
encode: Encoding.Base64,
token: undefined,
})
.then((res) => res.json())
.then((res) => res.results.map((res) => decodeQuestion(res, atob)));
```