---
lang: en
title: 'API docs: context.mergeinterceptors'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
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\]

<b>Signature:</b>

```typescript
export declare function mergeInterceptors(interceptorsFromSpec: InterceptorOrKey[], existingInterceptors: InterceptorOrKey[]): InterceptorOrKey[];
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  interceptorsFromSpec | <code>InterceptorOrKey[]</code> | Interceptors from <code>@intercept</code> |
|  existingInterceptors | <code>InterceptorOrKey[]</code> | Interceptors already applied for the method |

<b>Returns:</b>

`InterceptorOrKey[]`


