Page Contents
Home > @loopback/context > Context > getBinding
Context.getBinding() method
Look up a binding by key in the context and its ancestors. If no matching binding is found and options.optional is not set to true, an error will be thrown.
Signature:
getBinding<ValueType>(key: BindingAddress<ValueType>, options?: {
optional?: boolean;
}): Binding<ValueType> | undefined;
Parameters
| Parameter | Type | Description |
|---|---|---|
|
key |
BindingAddress<ValueType> |
Binding key |
|
options |
{ optional?: boolean; } |
(Optional) Options to control if the binding is optional. If |
Returns:
Binding<ValueType> | undefined