-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0531aa
commit c3cb24e
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { FilterOption } from "@/types/filters"; | ||
|
||
export async function fetchInterests(): Promise<FilterOption[]> { | ||
const url = | ||
"https://kudos-ink.github.io/repository-classification/interests.json"; | ||
|
||
try { | ||
const response = await fetch(url); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Failed to fetch data. Status: ${response.status}`); | ||
} | ||
|
||
const jsonData: { interests: FilterOption[] } = await response.json(); | ||
const { interests } = jsonData; | ||
return interests; | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
throw new Error("Failed to fetch interests data"); | ||
} | ||
} | ||
|
||
export async function fetchLanguages(): Promise<FilterOption[]> { | ||
const url = | ||
"https://kudos-ink.github.io/repository-classification/languages.json"; | ||
|
||
try { | ||
const response = await fetch(url); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Failed to fetch data. Status: ${response.status}`); | ||
} | ||
|
||
const languages: FilterOption[] = await response.json(); | ||
return languages; | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
throw new Error("Failed to fetch languages data"); | ||
} | ||
} | ||
|
||
export async function fetchRepositories(): Promise<FilterOption[]> { | ||
const url = | ||
"https://kudos-ink.github.io/repository-classification/repository_full.json"; | ||
|
||
try { | ||
const response = await fetch(url); | ||
|
||
if (!response.ok) { | ||
throw new Error(`Failed to fetch data. Status: ${response.status}`); | ||
} | ||
|
||
const jsonData: { repositories: FilterOption[] } = await response.json(); | ||
const { repositories } = jsonData; | ||
return repositories; | ||
} catch (error) { | ||
console.error("Error fetching data:", error); | ||
throw new Error("Failed to fetch projects data"); | ||
} | ||
} |