Applies a function to the value inside a successfully resolved Promise — curried p.then(onSuccess) for R.pipe. Part of Ramda Function since v0.27.1 (stable — not deprecated).
Note: Renamed from R.then so a Ramda helper would never look like a Promise thenable. Prefer R.andThen in all new code.
Syntax
Call R.andThen. Start with this line.
Ramda
R.andThen(onSuccess, p) or R.andThen(onSuccess)(p)
Call
What it does
R.andThen(onSuccess, p) or R.andThen(onSuccess)(p)
Primary signature.
R.andThen(...)
Call the function helper.
Prefer import { andThen } from "ramda" when you want a named import.
Library declarations
Ramda
R.andThen(onSuccess, p) or R.andThen(onSuccess)(p)
Parameters
Parameter
Description
onSuccess
Required. Function applied to the resolved value (may return a value or a Promise)
p
Required. A Promise / thenable
Return Value
Return Value
Description
*
A Promise: p.then(onSuccess)
Ramda Examples
Example 1 — Official getMemberName
Query → fetch → pick name fields after the Promise resolves.
Second Promise.fetchUser(42) returns another Promise.
Flatten.R.andThen waits for both, then yields the user object.
Same as native. Behavior matches Promise.prototype.then.
Compatibility
Browser & Runtime Support
R.andThen is a Ramda Function helper since v0.27.1. It delegates to Promise.prototype.then, so it needs Ramda 0.27.1+ and a Promise implementation (native in modern browsers and Node).
✓ Stable · Ramda 0.27.1+
R.andThen()
Works wherever Ramda 0.27.1+ and Promises are available — evergreen browsers (CDN or bundle), Node.js, Deno, and Bun. Internet Explorer needs a Promise polyfill.
100%With Ramda 0.27.1+ & Promises
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
R.andThenRamda 0.27.1+
Bottom line: Safe for production once Ramda 0.27.1+ and Promises are present. Load via CDN (ramda.min.js) or npm. Pair with R.otherwise for failures. Official reference: ramdajs.com/docs/#andThen.
Frequently Asked Questions
R.andThen(onSuccess, p) returns p.then(onSuccess). It applies onSuccess to the value inside a successfully resolved Promise. It is curried so it fits inside R.pipe.
getMemberName = R.pipe(makeQuery, fetchMember, R.andThen(pickName)). Calling getMemberName('[email protected]') resolves to { firstName: 'Bob', lastName: 'Loblaw' }. Added in v0.27.1. See also R.otherwise and R.pipeWith.
R.pipe passes each return value immediately. fetchMember returns a Promise object, not the member. R.pick on that Promise misses firstName/lastName and often yields {}. R.andThen waits, then runs pick.
Yes. Like Promise.prototype.then, if onSuccess returns a Promise, R.andThen flattens it to one Promise of the inner value.
R.andThen only runs on success. Pair it with R.otherwise (curried .catch) for the failure path.
No. It is a stable Ramda Function helper from v0.27.1. It replaced the older name R.then so it would not clash with Promise thenables. It is not deprecated, experimental, or non-standard.