Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/brecert/trivia-deno
- Owner: brecert
- Created: 2022-04-10T22:25:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-15T06:31:31.000Z (over 2 years ago)
- Last Synced: 2024-12-18T09:41:35.890Z (21 days ago)
- Language: TypeScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)));
```