@loopback/docs
Version:
Documentation for LoopBack 4
39 lines (26 loc) • 1.38 kB
Markdown
lang: en
title: 'API docs: context.invokemethod'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/context
permalink: /doc/en/lb4/apidocs.context.invokemethod.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/context](./context.md) > [invokeMethod](./context.invokemethod.md)
## invokeMethod() function
Invoke a method using dependency injection. Interceptors are invoked as part of the invocation.
<b>Signature:</b>
```typescript
export declare function invokeMethod(target: object, method: string, ctx: Context, nonInjectedArgs?: InvocationArgs, options?: InvocationOptions): ValueOrPromise<InvocationResult>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| target | <code>object</code> | Target of the method, it will be the class for a static method, and instance or class prototype for a prototype method |
| method | <code>string</code> | Name of the method |
| ctx | <code>Context</code> | Context object |
| nonInjectedArgs | <code>InvocationArgs</code> | Optional array of args for non-injected parameters |
| options | <code>InvocationOptions</code> | Options for the invocation |
<b>Returns:</b>
`ValueOrPromise<InvocationResult>`