@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
85 lines (43 loc) • 1.82 kB
Markdown
---
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) > [@loopback/context](./context.md) > [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\] =<!-- -->> \[cache, log\] - \[log\] + \[log, cache\] =<!-- -->> \[log, cache\] - \[\] + \[cache, log\] =<!-- -->> \[cache, log\] - \[cache, log\] + \[\] =<!-- -->> \[cache, log\] - \[log\] + \[cache\] =<!-- -->> \[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)<!-- -->\[\]