---
lang: en
title: 'API docs: context.transformvalueorpromise'
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.transformvalueorpromise.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/context](./context.md) &gt; [transformValueOrPromise](./context.transformvalueorpromise.md)

## transformValueOrPromise() function

Transform a value or promise with a function that produces a new value or promise

**Signature:**

```typescript
export declare function transformValueOrPromise<T, V>(valueOrPromise: ValueOrPromise<T>, transformer: (val: T) => ValueOrPromise<V>): ValueOrPromise<V>;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td markdown="1">

valueOrPromise


</td><td markdown="1">

[ValueOrPromise](./context.valueorpromise.md)<!-- -->&lt;T&gt;


</td><td markdown="1">

The value or promise


</td></tr>
<tr><td markdown="1">

transformer


</td><td markdown="1">

(val: T) =&gt; [ValueOrPromise](./context.valueorpromise.md)<!-- -->&lt;V&gt;


</td><td markdown="1">

A function that maps the source value to a value or promise


</td></tr>
</tbody></table>

**Returns:**

[ValueOrPromise](./context.valueorpromise.md)<!-- -->&lt;V&gt;


