Typescript support
This commit is contained in:
parent
354175ff2f
commit
0712a629a9
5 changed files with 40 additions and 7 deletions
21
app/api/picsum.ts
Normal file
21
app/api/picsum.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
export interface PicsumData {
|
||||
id: number,
|
||||
author: string,
|
||||
width: number,
|
||||
height: number,
|
||||
url: string,
|
||||
download_url: string
|
||||
}
|
||||
|
||||
export async function getPicsumData() {
|
||||
try {
|
||||
const response = await fetch('https://picsum.photos/v2/list');
|
||||
if (!response.ok) {
|
||||
throw new Error('Picsum API unavailable.');
|
||||
}
|
||||
const data: PicsumData[] = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Could not fetch data:", error);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue