What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-03 15:19:02
promise catch javascript
//create a Promise var p1 = new Promise(function(resolve, reject) { resolve("Success"); }); //Execute the body of the promise which call resolve //So it execute then, inside then there's a throw //that get capture by catch p1.then(function(va... Add solution -
Other 2021-08-31 12:43:01
sending value to promise
var some_function = function(username, password) { return new Promise(function(resolve, reject) { /*stuff using username, password*/ if ( /* everything turned out fine */ ) { resolve("Stuff worked!"); } else { reject(Error(&q... Add solution -
Javascript 2021-08-31 11:56:01
async await javascript stack overflow
function makePromise(x) { return new Promise(resolve => { setTimeout(() => { resolve(x); }, 1000); }); } async function asyncFunc() { var x = await makePromise(1); // the function is paused here until the prom... Add solution -
Javascript 2021-08-29 10:36:01
node wait 10 seconds
async function init() { console.log(1); await sleep(1000); console.log(2); } function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); } // one liner let sleep = ms => new Promise(resolve => setTimeout(re... Add solution -
Javascript 2021-08-27 13:55:01
use axios with Promise.all
const axios = require('axios'); const someFunction = () => { return new Promise(resolve => { setTimeout(() => resolve('222'), 100) }) } const requestsData = ['https://httpstat.us/200', 'https://httpstat.us/205', 'https://httpsta... Add solution -
SQL 2021-08-27 12:42:01
create database dynamically sql server using sequalize
const config = require('config.json'); const mysql = require('mysql2/promise'); const { Sequelize } = require('sequelize'); module.exports = db = {}; initialize(); async function initialize() { // create db if it doesn't already exist const { h... Add solution