@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
94 lines (50 loc) • 1.8 kB
Markdown
---
lang: en
title: 'API docs: context.context.get_1'
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.context.get_1.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/context](./context.md) > [Context](./context.context.md) > [get](./context.context.get_1.md)
## Context.get() method
Get the value bound to the given key, optionally return a (deep) property of the bound value.
**Signature:**
```typescript
get<ValueType>(keyWithPath: BindingAddress<ValueType>, options: ResolutionOptions): Promise<ValueType | undefined>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
keyWithPath
</td><td markdown="1">
[BindingAddress](./context.bindingaddress.md)<!-- --><ValueType>
</td><td markdown="1">
The binding key, optionally suffixed with a path to the (deeply) nested property to retrieve.
</td></tr>
<tr><td markdown="1">
options
</td><td markdown="1">
[ResolutionOptions](./context.resolutionoptions.md)
</td><td markdown="1">
Options for resolution.
</td></tr>
</tbody></table>
**Returns:**
Promise<ValueType \| undefined>
A promise of the bound value, or a promise of undefined when the optional binding is not found.
## Example
```ts
// get "rest" property from the value bound to "config"
// use `undefined` when no config is provided
const config = await ctx.get<RestComponentConfig>('config#rest', {
optional: true
});
```