1

I want to use NextFunction(next() for accessing next middleware) in the member functions of the class for redirecting to next middleware after sending mail.

File : Errors.ts

import { NextFunction, Request, Response } from 'express';

export class SettlementErrors extends Error {
    /**
     * Constructs the SettlementErrors class
     * @param {String} message an error message
     * @param {Error} errorStack Error Stack
     * @constructor
     */
    private errorstack;

    constructor(message:string,errorStack:Error) {

        super(message);
        this.errorstack = errorStack;
        this.sendEmail();//Call this function without sending req,res,next as params
    }

    //Send Error Mail Want to access **next** Here
    async sendEmail(request: Request, response: Response, next:NextFunction) : void
    {
    /**
            Code For Sending Email
      */
    }
}

How can I access next for switching to next middleware in member functions(function sendEmail) of this class ?? Thanks in advance

Vishwanath
  • 11
  • 4

0 Answers0