---
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) &gt; [@loopback/context](./context.md) &gt; [invokeMethod](./context.invokemethod.md)

## invokeMethod() function

Invoke a method using dependency injection. Interceptors are invoked as part of the invocation.

**Signature:**

```typescript
export declare function invokeMethod(target: object, method: string, ctx: Context, nonInjectedArgs?: InvocationArgs, options?: InvocationOptions): ValueOrPromise<InvocationResult>;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

target


</td><td>

object


</td><td>

Target of the method, it will be the class for a static method, and instance or class prototype for a prototype method


</td></tr>
<tr><td>

method


</td><td>

string


</td><td>

Name of the method


</td></tr>
<tr><td>

ctx


</td><td>

[Context](./context.context.md)


</td><td>

Context object


</td></tr>
<tr><td>

nonInjectedArgs


</td><td>

[InvocationArgs](./context.invocationargs.md)


</td><td>

_(Optional)_ Optional array of args for non-injected parameters


</td></tr>
<tr><td>

options


</td><td>

[InvocationOptions](./context.invocationoptions.md)


</td><td>

_(Optional)_ Options for the invocation


</td></tr>
</tbody></table>

**Returns:**

[ValueOrPromise](./context.valueorpromise.md)<!-- -->&lt;[InvocationResult](./context.invocationresult.md)<!-- -->&gt;


