Created
October 24, 2021 01:15
-
-
Save ximxim/1a7c69f9b6c8714f686aa5f6a6f08ca9 to your computer and use it in GitHub Desktop.
Nextjs handler api/tokens/[id] to send static NFT metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { NextApiRequest, NextApiResponse } from "next"; | |
/** | |
* | |
* @param req | |
* @param res | |
* | |
* This endpoint will return success response with an object that complies | |
* with OpenSea NFT standard. The object contains an image link to a giphy | |
* and the name of the asset. | |
* | |
* This handler can be used by making a get request to this link | |
* http://localhost:3000/api/tokens/1 | |
* | |
* Check: https://docs.opensea.io/docs/metadata-standards | |
*/ | |
async function handler(req: NextApiRequest, res: NextApiResponse) { | |
const tokenId = req.query.id as string; | |
res.status(200).json({ | |
image: `https://media.giphy.com/media/X7IoVUJXtO3wk/giphy.gif`, | |
name: `Giphy #${tokenId}`, | |
}); | |
} | |
export default handler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment