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();
Last updated on