A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sindresorhus/p-log below:

sindresorhus/p-log: Log the value/error of a promise

Log the value/error of a promise

import pLog from 'p-log';

Promise.resolve('unicorn')
	.then(pLog()) // Logs `unicorn`
	.then(value => {
		// `value` is still `unicorn`
	});
import pLog from 'p-log';

Promise.resolve()
	.then(() => {
		throw new Error('pony');
	})
	.catch(pLog.catch()) // Logs `Error: pony`
	.catch(error => {
		// `error` is still `Error: pony`
	});

Use this in a .then() method.

Returns a thunk that returns a Promise.

Use this in a .catch() method.

Returns a thunk that returns a Promise.

Type: Function
Default: console.log

The logger to use. Any return value or exception is ignored.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4