---
lang: en
title: 'API docs: context.binding.getvalue'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.context.binding.getvalue.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [Binding](./context.binding.md) &gt; [getValue](./context.binding.getvalue.md)

## Binding.getValue() method

This is an internal function optimized for performance. Users should use `@inject(key)` or `ctx.get(key)` instead.

Get the value bound to this key. Depending on `isSync`<!-- -->, this function returns either: - the bound value - a promise of the bound value

Consumers wishing to consume sync values directly should use `isPromiseLike` to check the type of the returned value to decide how to handle it.

<b>Signature:</b>

```typescript
getValue(ctx: Context, session?: ResolutionSession): ValueOrPromise<T>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  ctx | <code>Context</code> | Context for the resolution |
|  session | <code>ResolutionSession</code> | Optional session for binding and dependency resolution |

<b>Returns:</b>

`ValueOrPromise<T>`

## Example


```
const result = binding.getValue(ctx);
if (isPromiseLike(result)) {
  result.then(doSomething)
} else {
  doSomething(result);
}

```


