Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/bashmocha/quiz-api-app
- Owner: BashMocha
- Created: 2022-10-06T17:08:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-06T18:14:09.000Z (over 2 years ago)
- Last Synced: 2024-12-06T09:38:41.268Z (about 1 month ago)
- Topics: api, html-css-javascript
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.
## 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 = "";
}
````