f().then((res)=>{return`I got ${res}. When I did .then() on it`})
asyncfunctionfActual(){
returnPromise.resolve(1);
}
fActual().then((res)=>{return`The actual result is ${res} too`})
asyncfunctionfwithAwait(){
vara=awaitnewPromise((resolve,reject)=>{
setTimeout(()=>resolve(1),1000)
});
returna;
}
fwithAwait()
fwithAwait().then((res)=>`I got ${res}. So yes we can`)
fwithAwait().then((res)=>`First ${res}`)
.then((res)=>`Second ${res}`)
.then((res)=>`Third ${res}`)
.then((res)=>`Fourth ${res}`)
{
functionnormal(){
vara=newPromise((resolve,reject)=>{
setTimeout(()=>resolve(1),1000)
})
returnawaita;
}
returnnormal();
}
{
asyncfunctiongoat(){
letgoatImage=awaitfetch('http://goat-error');
returngoatImage;
}
returngoat().then(()=>`Success!`)
.catch((err)=>`Ther was an error: ${err} `);
}
{
asyncfunctiongoatFail(){
letgoatImage=awaitfetch('http://goat-error');
returngoatImage;
}
returngoatFail().then(()=>`Mutton Biryani`)
}
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.