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

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [intercept](./context.intercept.md)

## intercept() function

Decorator function `@intercept` for classes/methods to apply interceptors. It can be applied on a class and its public methods. Multiple occurrences of `@intercept` are allowed on the same target class or method. The decorator takes a list of `interceptor` functions or binding keys.

**Signature:**

```typescript
export declare function intercept(...interceptorOrKeys: InterceptorOrKey[]): (target: any, method?: string, methodDescriptor?: TypedPropertyDescriptor<any>) => any;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  interceptorOrKeys | [InterceptorOrKey](./context.interceptororkey.md)<!-- -->\[\] | One or more interceptors or binding keys that are resolved to be interceptors |

**Returns:**

(target: any, method?: string, methodDescriptor?: TypedPropertyDescriptor&lt;any&gt;) =&gt; any

## Example


```ts
@intercept(log, metrics)
class MyController {
  @intercept('caching-interceptor')
  @intercept('name-validation-interceptor')
  greet(name: string) {
    return `Hello, ${name}`;
  }
}
```


