mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-04-30 18:59:37 +00:00
Updated how Images are Handeled to Comply With Unsplash API Guidelines
This commit is contained in:
parent
d99f17c9d1
commit
01bebf0d83
3 changed files with 42 additions and 13 deletions
20
app/api/unsplash/route.ts
Normal file
20
app/api/unsplash/route.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { unsplash } from '@/lib/unsplash';
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const result = await unsplash.photos.getRandom({
|
||||
collectionIds: ['317099'],
|
||||
count: 9,
|
||||
});
|
||||
|
||||
if (result?.response) {
|
||||
const newImages = result.response as Array<Record<string, any>>;
|
||||
return new NextResponse(JSON.stringify(newImages), { status: 200 });
|
||||
} else {
|
||||
return new NextResponse('Failed to get images', { status: 500 });
|
||||
}
|
||||
} catch (error) {
|
||||
return new NextResponse(JSON.stringify(error), { status: 500 });
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue