Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

can i use promise.all conditional in vue js

const promises = [];

if(true) {
   const promise1 = fetch('https://jsonplaceholder.typicode.com/posts/1').then(res => ({ res: res, promise: 'promise1' }));
   promises.push(promise1);
}

if(false) {
   const promise2 = fetch('https://jsonplaceholder.typicode.com/posts/2').then(res => ({ res: res, promise: 'promise2' }));
   promises.push(promise2);
}

Promise.all(promises).then(res => console.log(res));
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #conditional #vue #js
ADD COMMENT
Topic
Name
7+7 =