mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-24 15:10:33 +00:00
feat: switch to static tweets
This commit is contained in:
25
api/get-tweet-ast/[tweetId].ts
Normal file
25
api/get-tweet-ast/[tweetId].ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { fetchTweetAst } from 'static-tweets'
|
||||
|
||||
export default async (
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
): Promise<void> => {
|
||||
if (req.method !== 'GET') {
|
||||
return res.status(405).send({ error: 'method not allowed' })
|
||||
}
|
||||
|
||||
const tweetId = req.query.tweetId as string
|
||||
|
||||
if (!tweetId) {
|
||||
return res
|
||||
.status(400)
|
||||
.send({ error: 'missing required parameter "tweetId"' })
|
||||
}
|
||||
|
||||
console.log('getTweetAst', tweetId)
|
||||
const tweetAst = await fetchTweetAst(tweetId)
|
||||
console.log('tweetAst', tweetId, tweetAst)
|
||||
|
||||
res.status(200).json(tweetAst)
|
||||
}
|
||||
Reference in New Issue
Block a user