@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
96 lines (50 loc) • 1.97 kB
Markdown
---
lang: en
title: 'API docs: context.context.getsync'
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.getsync.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/context](./context.md) > [Context](./context.context.md) > [getSync](./context.context.getsync.md)
## Context.getSync() method
Get the synchronous value bound to the given key, optionally return a (deep) property of the bound value.
This method throws an error if the bound value requires async computation (returns a promise). You should never rely on sync bindings in production code.
**Signature:**
```typescript
getSync<ValueType>(keyWithPath: BindingAddress<ValueType>, session?: ResolutionSession): ValueType;
```
## 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">
session
</td><td markdown="1">
[ResolutionSession](./context.resolutionsession.md)
</td><td markdown="1">
_(Optional)_ Session for resolution (accepted for backward compatibility)
</td></tr>
</tbody></table>
**Returns:**
ValueType
A promise of the bound value.
## Example
```ts
// get the value bound to "application.instance"
const app = ctx.getSync<Application>('application.instance');
// get "rest" property from the value bound to "config"
const config = await ctx.getSync<RestComponentConfig>('config#rest');
```