Advertisement
LagExpress

API Route

Feb 5th, 2023
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.57 KB | Source Code | 0 0
  1. // Server code || pages/api/upload2.tsx
  2. import { NextApiRequest, NextApiResponse } from 'next'
  3.  
  4. export default async function upload(req: NextApiRequest, res: NextApiResponse) {
  5.     if (req.method === 'POST') {
  6.         try {
  7.             const { file, company } = req.body;
  8.  
  9.             console.log(company)
  10.  
  11.             return res.status(200).send({ message: 'data successfully received.' })
  12.         } catch (error) {
  13.             return res.status(500).send({ message: error.message })
  14.         }
  15.     }
  16.  
  17.     return res.status(405).send({ message: 'Method Not Allowed' })
  18. }
Tags: Next.js
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement