Advertisement
rezacute

[twin-nft].ts

Jul 15th, 2022
1,434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import type {
  2.     NextApiRequest,
  3.     NextApiResponse
  4. } from 'next'
  5. const axios = require('axios')
  6.  
  7. // Wallet address
  8. const address = '0x345e92122c1c0ac81d3147d4cc7f6345a6f16926'
  9.  
  10. // Alchemy URL
  11. const baseURL = `https://polygon-mumbai.g.alchemy.com/v2/s6uKR0ijFvK1srMLj2wyWR5zmAFBUo0s`;
  12. const url = `${baseURL}/getNFTs/?owner=${address}`;
  13.  
  14. const config = {
  15.     method: 'get',
  16.     url: url,
  17. };
  18.  
  19. // Make the request and print the formatted response:
  20.  
  21. export default async function handleNFT(
  22.     req: NextApiRequest,
  23.     res: NextApiResponse
  24. ) {
  25.     const {
  26.     } = req;
  27.     let data: any;
  28.     await axios(config)
  29.         .then((response: { [x: string]: any; }) => {
  30.             data = response['data']
  31.             console.log(response['data'])
  32.         })
  33.         .catch((error: any) => console.log('error', error));
  34.     res.statusCode = 200;
  35.     res.setHeader('Content-Type', 'application/json');
  36.     res.end(
  37.         JSON.stringify(
  38.             data
  39.         )
  40.     );
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement