Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bashmocha/quiz-api-app

A web application with multiple choice quiz questions with Open Trivia DB API
https://github.com/bashmocha/quiz-api-app

api html-css-javascript

Last synced: 26 days ago
JSON representation

A web application with multiple choice quiz questions with Open Trivia DB API

Awesome Lists containing this project

README

        

# Quiz Game - API
Here is an web application written in vanilla Javascript, CSS and HTML5. I used Open Trivia Database API for the questions.


Quick Look

## API for Request
[Quiz API](https://opentdb.com/api_config.php)

## API Usage

- To create a URL object, pass the URL as a string into a const.
- To start a request, call the special function ````fetch()```` and pass the url object as an argument.
- The method returns a promise, so you have to wait for the JSON: ````await result.json()````.

````
async function loadQuestion() {
const APIUrl = 'https://opentdb.com/api.php?amount=1';
const result = await fetch(`${APIUrl}`);
const data = await result.json();
showQuestion(data.results[0]);
_result.innerHTML = "";
}
````