mirror of
https://github.com/UiO-Gaming/name-100-uio-gamers.git
synced 2026-11-05 13:56:53 +01:00
define API return type
This commit is contained in:
2 files changed
+14
-2
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import type { Match } from "@/types";
|
||||
import type { Match, NorwegianPersonItem } from "@/types";
|
||||
|
||||
export async function findNorwegianPerson(input: string): Promise<Match> {
|
||||
const apiUrl = `https://snl.no/api/v1/search?query=${encodeURIComponent(input)}&limit=5`;
|
||||
const response = await fetch(apiUrl);
|
||||
const data = await response.json();
|
||||
|
||||
function isNorwegianPerson(item: any): boolean {
|
||||
function isNorwegianPerson(item: NorwegianPersonItem): boolean {
|
||||
// Must be a biography
|
||||
if (item.article_type_id !== 2) return false;
|
||||
|
||||
|
||||
@@ -4,3 +4,15 @@ export interface Match {
|
||||
description: string | undefined;
|
||||
correct: boolean;
|
||||
}
|
||||
|
||||
export interface NorwegianPersonItem {
|
||||
article_type_id: number;
|
||||
rank: number;
|
||||
taxonomy_title?: string;
|
||||
subject_title?: string;
|
||||
first_sentences?: string;
|
||||
snippet?: string;
|
||||
title?: string;
|
||||
headword?: string;
|
||||
article_url_json?: string;
|
||||
}
|
||||
Reference in new issue
Block a user