What do you want to save?
Add Code snippet
New code examples
-
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-15 12:05:02
react map wait axios call
const postIds = ['123', 'dn28e29', 'dn22je3']; const posts = posts.map(post => { return axios .get(`https://example.com/post/${post.id}`) .then(res => res.data) .catch(e => console.error(e)); } Promise.all(posts).then(res => co... Add solution -
Javascript 2021-09-14 18:52:02
how to implement a promise with daisy chaining in angular
private firstAction():Promise<any> { return new Promise<any>( (resolve, reject) => { ... } ); } private secondAction():Promise<any> { return new Promise<any>( (resolve, reject) => { ... } ); } execute() { th... Add solution -
Javascript 2021-09-12 03:18:02
Each then() should return a value or throw
outer.get('/account', function(req, res) { var id = req.user.uid var userRef = firebase.db.collection('users').doc(id) var profilePromise = userRef.get().then(doc => { if (doc.exists) { var profile = doc.data() profile.id = doc.id... 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-11 05:57:02
facebook integration in node.js
const request = require('request-promise'); module.exports = (app) => { // you'll need to have requested 'user_about_me' permissions // in order to get 'quotes' and 'about' fields from search const userFieldSet = 'name, link, is_verified, pictu... Add solution