From c11ddeaf38c10f281e874cf2049c852f8bf81628 Mon Sep 17 00:00:00 2001 From: Jaronem Date: Mon, 16 Sep 2024 08:19:50 +0200 Subject: [PATCH] nextMiddleware may be undefined --- docs/CustomMiddlewareChain.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/CustomMiddlewareChain.md b/docs/CustomMiddlewareChain.md index 6615bc7eb..d15e7897b 100644 --- a/docs/CustomMiddlewareChain.md +++ b/docs/CustomMiddlewareChain.md @@ -117,7 +117,7 @@ import { Middleware } from "@microsoft/microsoft-graph-client"; import { Context } from "@microsoft/microsoft-graph-client"; export class MyLoggingHandler implements Middleware { - private nextMiddleware: Middleware; + private nextMiddleware: Middleware | undefined; public async execute(context: Context): Promise { try { @@ -132,7 +132,9 @@ export class MyLoggingHandler implements Middleware { } else { console.log(url); } - await this.nextMiddleware.execute(context); + if (this.nextMiddleware) { + await this.nextMiddleware.execute(context); + } } catch (error) { throw error; }