---
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

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

interceptorOrKeys


</td><td markdown="1">

[InterceptorOrKey](./context.interceptororkey.md)<!-- -->\[\]


</td><td markdown="1">

One or more interceptors or binding keys that are resolved to be interceptors


</td></tr>
</tbody></table>

**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}`;
  }
}
```


