What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-10 04:17:03
nodejs promise async
// server.js function square(x) { return new Promise(resolve => { setTimeout(() => { resolve(Math.pow(x, 2)); }, 2000); }); } async function layer(x) { const value =... Add solution -
Javascript 2021-09-08 04:01:03
async sleep javascript
const sleep = (milliseconds) => { return new Promise(resolve => setTimeout(resolve, milliseconds)) } /*Use like so*/ async function timeSensativeAction(){ //must be async func //do something here await sleep(5000) //wait 5 seconds //contin... Add solution -
Javascript 2021-09-05 22:44:02
javascript sleep function
const sleep = (milliseconds) => { return new Promise(resolve => setTimeout(resolve, milliseconds)) } /*Use like so*/ async function timeSensativeAction(){ //must be async func //do something here await sleep(5000) //wait 5 seconds //contin... Add solution -
Other 2021-09-05 13:14:02
knex migrate in docker compose
"use strict"; const config = require("./knexfile"); const Knex = require("knex"); const knex = Knex(config); async function runMigrations(retries, delay) { for (let i = 1; i !== retries; i++) { try { return awa... 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