JSFiddle - React, Tailwind, and code Playground
by Rajdeep Chandra
JavaScript
function printNumber1() {
return new Promise((resolve, reject) => {
console.log("Firing 1")
fetch('https://pokeapi.co/api/v2/type/4/')
.then(res => res.json())
.then(result => result)
});
}
function printNumber2() {
return new Promise((resolve, reject) => {
console.log("Firing 2")
fetch('https://pokeapi.co/api/v2/type/3/')
.then(res => res.json())
.then(result => result)
});
}
window.onload = function() {
async function inParallel() {
const promise1 = printNumber1();
const promise2 = printNumber2();
const number1 = await promise1;
const number2 = await promise2;
}
}