What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-16 10:18:08
vue electron read file
import fs from 'fs' import readline from 'readline' import iconv from 'iconv-lite' ipcMain.on('readfile', async (event, arg) => { await readLines() event.sender.send('readfile-reply', 'complete') }) function readLines() { return new Promi... Add solution -
Javascript 2021-10-15 00:10:04
return new Promise(res => {
var promise = new Promise(function(resolve, reject) { // do some long running async thing… if (/* everything turned out fine */) { resolve("Stuff worked!"); } else { reject(Error("It broke")); }... Add solution -
Javascript 2021-10-13 06:20:07
begin transaction in node js using pool query
module.exports = { creatUser: (req) => { return new Promise((resolve, reject) => { pool.getConnection(function (err, connection) { connection.beginTransaction(function (err) { if (err) { //Transaction Error ... Add solution -
Javascript 2021-10-09 19:18:03
promise catch
//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 -
Javascript 2021-10-08 07:53:11
nodejs download image from url
const request = require('request'); const fs = require('fs'); async function download(url, dest) { /* Create an empty file where we can save data */ const file = fs.createWriteStream(dest); /* Using Promises so that we can use the ASYNC AWA... Add solution -
Javascript 2021-10-05 09:50:05
download image in nodejs
const request = require('request'); const fs = require('fs'); async function download(url, dest) { /* Create an empty file where we can save data */ const file = fs.createWriteStream(dest); /* Using Promises so that we can use the ASYNC AWA... Add solution -
Javascript 2021-10-05 05:46:02
simulate schrool event puppeter
const autoScroll = async (page) => { await page.evaluate(async () => { await new Promise((resolve, reject) => { let totalHeight = 0 let distance = 100 let timer = setInterval(() => { let scrollHeight = document.... Add solution