---
lang: en
title: 'API docs: context.mergeinterceptors'
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.mergeinterceptors.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [mergeInterceptors](./context.mergeinterceptors.md)

## mergeInterceptors() function

Adding interceptors from the spec to the front of existing ones. Duplicate entries are eliminated from the spec side.

For example:

- \[log\] + \[cache, log\] =<!-- -->&gt; \[cache, log\] - \[log\] + \[log, cache\] =<!-- -->&gt; \[log, cache\] - \[\] + \[cache, log\] =<!-- -->&gt; \[cache, log\] - \[cache, log\] + \[\] =<!-- -->&gt; \[cache, log\] - \[log\] + \[cache\] =<!-- -->&gt; \[log, cache\]

**Signature:**

```typescript
export declare function mergeInterceptors(interceptorsFromSpec: InterceptorOrKey[], existingInterceptors: InterceptorOrKey[]): InterceptorOrKey[];
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

interceptorsFromSpec


</td><td markdown="1">

[InterceptorOrKey](./context.interceptororkey.md)<!-- -->\[\]


</td><td markdown="1">

Interceptors from `@intercept`


</td></tr>
<tr><td markdown="1">

existingInterceptors


</td><td markdown="1">

[InterceptorOrKey](./context.interceptororkey.md)<!-- -->\[\]


</td><td markdown="1">

Interceptors already applied for the method


</td></tr>
</tbody></table>

**Returns:**

[InterceptorOrKey](./context.interceptororkey.md)<!-- -->\[\]


