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

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

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [MiddlewareSequence](./rest.middlewaresequence.md) &gt; [handle](./rest.middlewaresequence.handle.md)

## MiddlewareSequence.handle() method

Runs the default sequence. Given a handler context (request and response), running the sequence will produce a response or an error.

Default sequence executes these groups of middleware:

- `cors`<!-- -->: Enforces `CORS` - `openApiSpec`<!-- -->: Serves OpenAPI specs - `findRoute`<!-- -->: Finds the appropriate controller method, swagger spec and args for invocation - `parseParams`<!-- -->: Parses HTTP request to get API argument list - `invokeMethod`<!-- -->: Invokes the API which is defined in the Application controller method

In front of the groups above, we have a special middleware called `sendResponse`<!-- -->, which first invokes downstream middleware to get a result and handles the result or error respectively.

- Writes the result from API into the HTTP response (if the HTTP response has not been produced yet by the middleware chain. - Catches error logs it using 'logError' if any of the above steps in the sequence fails with an error.

<b>Signature:</b>

```typescript
handle(context: RequestContext): Promise<void>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  context | [RequestContext](./rest.requestcontext.md) | The request context: HTTP request and response objects, per-request IoC container and more. |

<b>Returns:</b>

Promise&lt;void&gt;


