Skip to Content
Mika Scraper 1.1.1 is released πŸŽ‰
πŸƒ MIKA FUNCTIONFunction: GuessTheFlag()

Mika Scraper v1.1.2


Mika Scraper / GuessTheFlag

Function: GuessTheFlag()

GuessTheFlag(): Promise<FlagQuestion>

Defined in: src/games/guess-flag.ts:20

Fetches and constructs a β€œGuess the Flag” question using real-time country data from the RESTCountries API.

Returns

A Promise that resolves to a FlagQuestion object, which includes the following properties:

  • flagImageUrl: string - The URL of the flag image associated with the question.
  • correctAnswer: string - The correct country name corresponding to the displayed flag.
  • options: Array<string> - An array of answer options, including the correct answer and several distractors.

Example

import { GuessTheFlag } from 'mika-scraper'; async function displayFlagQuestion() { const flagQuestion = await GuessTheFlag(); console.log('Flag Image URL:', flagQuestion.flagImageUrl); console.log('Correct Answer:', flagQuestion.correctAnswer); console.log('Options:', flagQuestion.options); } displayFlagQuestion();

Diagram: Mika Scraper

Last updated on