your recipe card header background

    Next API with middleware

    0

    1

    Jose Romero

    nextapimiddleware
    NextJS Javascript Recipes

    Next API with middleware

    Library: next

    Shortcut: next.api.middleware.create

    function runMiddleware(req, res, fn) {
      return new Promise((resolve, reject) => {
        fn(req, res, (result) => {
          if (result instanceof Error) {
            return reject(result)
          }
          return resolve(result)
        })
      })
    }
    async function handler(req, res) {
      await runMiddleware(req, res, (req, res, fn) => {
      	
      })
    	
      res.json({})
    }
    export default handler
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.