---
lang: en
title: 'API docs: express.getmiddlewarecontext'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/express
permalink: /doc/en/lb4/apidocs.express.getmiddlewarecontext.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/express](./express.md) &gt; [getMiddlewareContext](./express.getmiddlewarecontext.md)

## getMiddlewareContext() function

A helper function to retrieve the MiddlewareContext/RequestContext from the request object

<b>Signature:</b>

```typescript
export declare function getMiddlewareContext<T extends MiddlewareContext = MiddlewareContext>(request?: Request): T | undefined;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  request | Request | <i>(Optional)</i> Express request object |

<b>Returns:</b>

T \| undefined


