mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-12-14 21:32:32 -05:00
formatting
This commit is contained in:
@@ -4,10 +4,13 @@ export async function GET(request: Request) {
|
||||
const apiKey = process.env.NEYNAR_API_KEY;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const fid = searchParams.get('fid');
|
||||
|
||||
|
||||
if (!apiKey) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Neynar API key is not configured. Please add NEYNAR_API_KEY to your environment variables.' },
|
||||
{
|
||||
error:
|
||||
'Neynar API key is not configured. Please add NEYNAR_API_KEY to your environment variables.',
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
@@ -24,7 +27,7 @@ export async function GET(request: Request) {
|
||||
`https://api.neynar.com/v2/farcaster/user/best_friends?fid=${fid}&limit=3`,
|
||||
{
|
||||
headers: {
|
||||
"x-api-key": apiKey,
|
||||
'x-api-key': apiKey,
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -33,14 +36,19 @@ export async function GET(request: Request) {
|
||||
throw new Error(`Neynar API error: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const { users } = await response.json() as { users: { user: { fid: number; username: string } }[] };
|
||||
const { users } = (await response.json()) as {
|
||||
users: { user: { fid: number; username: string } }[];
|
||||
};
|
||||
|
||||
return NextResponse.json({ bestFriends: users });
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch best friends:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch best friends. Please check your Neynar API key and try again.' },
|
||||
{
|
||||
error:
|
||||
'Failed to fetch best friends. Please check your Neynar API key and try again.',
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user