What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-01-22 13:26:56
nextjs Access-Control-Allow-Origin
//npm i cors //# or //yarn add cors import Cors from 'cors' // Initializing the cors middleware const cors = Cors({ methods: ['GET', 'HEAD'], }) // Helper method to wait for a middleware to execute before continuing // And to throw an error when an ... Add solution -
Javascript 2022-01-22 07:25:19
wrap wreck request inside async block
const asyncOperation = () => { return new Promise((resolve, reject) => { setTimeout(()=>{resolve("hi")}, 3000) }) } const asyncFunction = async (callback) => { let res = await asyncOperation(); callback(res);... Add solution -
Javascript 2021-11-18 22:48:15
javascript 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