Next.js Discord

Discord Forum

Nextjs@15.1.0 Fails to build api routes

Answered
AM posted this in #help-forum
Open in Discord
Avatar
AMOP
I have following api route:

http://localhost:3001/api/trending/{id}

import { neynar } from '@/lib/services/Neynar';
import { augmentCasts } from '@/lib/utils';
import { fetchTrendingPosts } from '@/lib/utils/neynar';
import { NextRequest, NextResponse } from 'next/server';

export async function GET(
  request: NextRequest,
  { params }: { params: Promise<{ fid: string }> }
) {
  const { fid } = await params;

  const castsWithScores = await fetchTrendingPosts({
    fid: Number(fid)
  });

  if (!castsWithScores) {
    return {
      casts: []
    };
  }

  const hashes = castsWithScores.map((cast) => cast[0]);

  const response = await neynar.getBulkCasts(hashes);

  const augmentedCasts = await augmentCasts(response.result.casts);

  return NextResponse.json({
    casts: augmentedCasts
  });
}


But on build i get following error:

https://pastebin.com/Uf3r1wNW any ideas?
Answered by joulev
not
return {
  casts: []
};

but
return NextResponse.json({
  casts: []
});
View full answer

2 Replies

Avatar
not
return {
  casts: []
};

but
return NextResponse.json({
  casts: []
});
Answer
Avatar
AMOP
ah what a miss! you are the best!