@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
39 lines (26 loc) • 1.52 kB
Markdown
---
lang: en
title: 'API docs: context.invokemethod'
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.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 | object | Target of the method, it will be the class for a static method, and instance or class prototype for a prototype method |
| method | string | Name of the method |
| ctx | [Context](./context.context.md) | Context object |
| nonInjectedArgs | [InvocationArgs](./context.invocationargs.md) | Optional array of args for non-injected parameters |
| options | [InvocationOptions](./context.invocationoptions.md) | Options for the invocation |
<b>Returns:</b>
[ValueOrPromise](./context.valueorpromise.md)<!-- --><[InvocationResult](./context.invocationresult.md)<!-- -->>