Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🏗️ Build (push) Failing after 14s
Build & Deploy / 🧪 QA (push) Failing after 1m48s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
23 lines
622 B
TypeScript
23 lines
622 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getTweet } from 'react-tweet/api';
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const { id } = await params;
|
|
|
|
try {
|
|
const tweet = await getTweet(id);
|
|
|
|
if (!tweet) {
|
|
return NextResponse.json({ error: 'Tweet not found' }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({ data: tweet });
|
|
} catch (error) {
|
|
console.error('Error fetching tweet:', error);
|
|
return NextResponse.json({ error: 'Failed to fetch tweet' }, { status: 500 });
|
|
}
|
|
}
|