-
        SummaryDoubt: Generated types expect params to be a Promise (which is incorrect for a dynamic route). Any help is much appreciated! Additional informationhere is the build error:
.next/types/app/api/spotify/[endpoint]/route.ts:49:7
Type error: Type '{ __tag__: "GET"; __param_position__: "second"; __param_type__: { params: { endpoint: string; }; }; }' does not satisfy the constraint 'ParamCheck<RouteContext>'.
  The types of '__param_type__.params' are incompatible between these types.
    Type '{ endpoint: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
  47 |     Diff<
  48 |       ParamCheck<RouteContext>,
> 49 |       {
     |       ^
  50 |         __tag__: 'GET'
  51 |         __param_position__: 'second'
  52 |         __param_type__: SecondArg<MaybeField<TEntry, 'GET'>>
Next.js build worker exited with code: 1 and signal: null
here is the related code snippet:
import { NextResponse } from 'next/server';
import axios from 'axios';
import NodeCache from 'node-cache';
import { getAccessToken } from '@/lib/spotify';
const cache = new NodeCache({ stdTTL: 3 });
export async function GET(request: Request, { params }: { params: { endpoint: string } }) {
  const { endpoint } = params;
  const cacheKey = `spotify-${endpoint}`;
  const cached = cache.get(cacheKey);
  if (cached) return NextResponse.json(cached);
  const accessToken = await getAccessToken();
  if (!accessToken) {
    return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
  }
  let url = '';
  if (endpoint === 'currently-playing') {
    url = 'https://api.spotify.com/v1/me/player/currently-playing';
  } else if (endpoint === 'top-track') {
    url = 'https://api.spotify.com/v1/me/top/tracks?time_range=short_term&limit=1';
  } else {
    return NextResponse.json({ error: 'Invalid endpoint' }, { status: 400 });
  }
  try {
    const response = await axios.get(url, {
      headers: { Authorization: `Bearer ${accessToken}` },
    });
    const data = endpoint === 'top-track' ? response.data.items[0] || null : response.data || null;
    cache.set(cacheKey, data);
    return NextResponse.json(data);
  } catch (err: any) {
    return NextResponse.json({ error: 'Error fetching data' }, { status: err.response?.status || 500 });
  }
}ExampleNo response  | 
  
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            icyJoseph
          
      
      
        May 23, 2025 
      
    
    Replies: 1 comment 1 reply
-
| 
         Change your function signature to: export async function GET(request: Request, { params }: { params: Promise<{ endpoint: string }> }) {
    const { endpoint } = await params;Next 15 had breaking changes: https://nextjs.org/docs/app/guides/upgrading/version-15#route-handlers  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
      Answer selected by
        CalmNerd
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Change your function signature to:
Next 15 had breaking changes: https://nextjs.org/docs/app/guides/upgrading/version-15#route-handlers