What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-20 16:12:02
promise all in promise all
var p1 = Promise.resolve(3); var p2 = 1337; var p3 = new Promise((resolve, reject) => { setTimeout(resolve, 100, "foo"); }); Promise.all([p1, p2, p3]).then(values => { console.log(values); // [3, 1337, "foo"] }); Add solution -
Javascript 2021-09-16 19:33:02
serverless and connections mongodb atlas
const mongoose = require('mongoose'); mongoose.Promise = global.Promise; let isConnected; module.exports = connectToDatabase = () => { if (isConnected) { console.log('=> using existing database connection'); return Promise.resolve(); } ... Add solution -
Javascript 2021-09-11 07:06:02
resolve vs return promise js
In simple terms, inside a then handler function: A) When x is a value (number, string, etc): - return x is equivalent to return Promise.resolve(x) - throw x is equivalent to return Promise.reject(x) B) When x is a Promise that is already settled (not ... Add solution -
Javascript 2021-09-06 05:31:02
async reduce javascript
const getNonSemverPatchPRs = async () => { const allOpenPrs = await getAllOpenPRs(); return allOpenPrs.reduce(async (previousPromise, pr) => { const collection = await previousPromise; const allCommits = await getAllCommitsF... Add solution