Promise.resolve()

Added in ves6 · Updated March 13, 2026 · Async APIs
promise async es6 javascript

The Promise.resolve() static method returns a Promise object that is resolved with a given value. It provides a way to wrap synchronous values into promises.

Syntax

Promise.resolve(value)

Parameters

ParameterTypeDescription
valueanyThe value to resolve with. Can be a plain value, a thenable, or an existing Promise

Return Value

  • If the value is a Promise, returns that Promise
  • If the value is a thenable (object with a then method), returns a Promise that follows that thenable
  • Otherwise, returns a new Promise resolved with the value

Examples

Basic Usage

// Resolve with a plain value
const promise = Promise.resolve(42);
promise.then(result => console.log(result)); // 42

// Shortcut for new Promise(resolve => resolve(value))
const data = Promise.resolve({ id: 1, name: "Alice" });

Using with Thenables

// A thenable is any object with a .then() method
const thenable = {
  then(resolve, reject) {
    resolve(42);
  }
};

Promise.resolve(thenable).then(result => {
  console.log(result); // 42
});

Ensuring a Function Always Returns a Promise

function getData(id) {
  // If data is already available, wrap it
  // If it's a promise, return it as-is
  return Promise.resolve(cache[id] || fetchFromNetwork(id));
}

// This works whether the source is sync or async
const result1 = getData("cached-item");
const result2 = getData("remote-item");

Converting Callback APIs

function readFilePromise(path) {
  return Promise.resolve(fs.readFileSync(path));
}

Key Behaviors

  • Identity function for promises: If passed a Promise, it returns that exact Promise (not a wrapper)
  • Thenables: Automatically adopts the state of thenables, waiting for their resolution
  • Undefined: Promise.resolve() returns a resolved Promise with undefined

Common Pitfalls

// AVOID: Unnecessary wrapping
const p = Promise.resolve(Promise.resolve(42));
// The inner Promise.resolve is redundant

// CORRECT: Direct pass-through
const p = Promise.resolve(existingPromise);

See Also