[{"data":1,"prerenderedAt":610},["ShallowReactive",2],{"content-\u002Fjavascript\u002Fpromises":3,"related-\u002Fjavascript\u002Fpromises":480,"sidebar-content":584},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"tags":10,"date":13,"body":14,"_type":474,"_id":475,"_source":476,"_file":477,"_stem":478,"_extension":479},"\u002Fjavascript\u002Fpromises","javascript",false,"","Promise Patterns","Common JavaScript promise patterns and async\u002Fawait usage",[5,11,12],"frontend","async","2026-03-12",{"type":15,"children":16,"toc":470},"root",[17,26,32,231,237,242,464],{"type":18,"tag":19,"props":20,"children":22},"element","h2",{"id":21},"promiseall",[23],{"type":24,"value":25},"text","Promise.all",{"type":18,"tag":27,"props":28,"children":29},"p",{},[30],{"type":24,"value":31},"Run multiple promises in parallel:",{"type":18,"tag":33,"props":34,"children":38},"pre",{"className":35,"code":36,"language":37,"meta":7,"style":7},"language-js shiki shiki-themes github-light github-dark","const [users, posts] = await Promise.all([\n  fetch('\u002Fapi\u002Fusers').then(r => r.json()),\n  fetch('\u002Fapi\u002Fposts').then(r => r.json()),\n])\n","js",[39],{"type":18,"tag":40,"props":41,"children":42},"code",{"__ignoreMap":7},[43,113,173,222],{"type":18,"tag":44,"props":45,"children":48},"span",{"class":46,"line":47},"line",1,[49,55,61,67,72,77,82,87,92,97,102,108],{"type":18,"tag":44,"props":50,"children":52},{"style":51},"--shiki-default:#D73A49;--shiki-dark:#F97583",[53],{"type":24,"value":54},"const",{"type":18,"tag":44,"props":56,"children":58},{"style":57},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[59],{"type":24,"value":60}," [",{"type":18,"tag":44,"props":62,"children":64},{"style":63},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[65],{"type":24,"value":66},"users",{"type":18,"tag":44,"props":68,"children":69},{"style":57},[70],{"type":24,"value":71},", ",{"type":18,"tag":44,"props":73,"children":74},{"style":63},[75],{"type":24,"value":76},"posts",{"type":18,"tag":44,"props":78,"children":79},{"style":57},[80],{"type":24,"value":81},"] ",{"type":18,"tag":44,"props":83,"children":84},{"style":51},[85],{"type":24,"value":86},"=",{"type":18,"tag":44,"props":88,"children":89},{"style":51},[90],{"type":24,"value":91}," await",{"type":18,"tag":44,"props":93,"children":94},{"style":63},[95],{"type":24,"value":96}," Promise",{"type":18,"tag":44,"props":98,"children":99},{"style":57},[100],{"type":24,"value":101},".",{"type":18,"tag":44,"props":103,"children":105},{"style":104},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[106],{"type":24,"value":107},"all",{"type":18,"tag":44,"props":109,"children":110},{"style":57},[111],{"type":24,"value":112},"([\n",{"type":18,"tag":44,"props":114,"children":116},{"class":46,"line":115},2,[117,122,127,133,138,143,147,153,158,163,168],{"type":18,"tag":44,"props":118,"children":119},{"style":104},[120],{"type":24,"value":121},"  fetch",{"type":18,"tag":44,"props":123,"children":124},{"style":57},[125],{"type":24,"value":126},"(",{"type":18,"tag":44,"props":128,"children":130},{"style":129},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[131],{"type":24,"value":132},"'\u002Fapi\u002Fusers'",{"type":18,"tag":44,"props":134,"children":135},{"style":57},[136],{"type":24,"value":137},").",{"type":18,"tag":44,"props":139,"children":140},{"style":104},[141],{"type":24,"value":142},"then",{"type":18,"tag":44,"props":144,"children":145},{"style":57},[146],{"type":24,"value":126},{"type":18,"tag":44,"props":148,"children":150},{"style":149},"--shiki-default:#E36209;--shiki-dark:#FFAB70",[151],{"type":24,"value":152},"r",{"type":18,"tag":44,"props":154,"children":155},{"style":51},[156],{"type":24,"value":157}," =>",{"type":18,"tag":44,"props":159,"children":160},{"style":57},[161],{"type":24,"value":162}," r.",{"type":18,"tag":44,"props":164,"children":165},{"style":104},[166],{"type":24,"value":167},"json",{"type":18,"tag":44,"props":169,"children":170},{"style":57},[171],{"type":24,"value":172},"()),\n",{"type":18,"tag":44,"props":174,"children":176},{"class":46,"line":175},3,[177,181,185,190,194,198,202,206,210,214,218],{"type":18,"tag":44,"props":178,"children":179},{"style":104},[180],{"type":24,"value":121},{"type":18,"tag":44,"props":182,"children":183},{"style":57},[184],{"type":24,"value":126},{"type":18,"tag":44,"props":186,"children":187},{"style":129},[188],{"type":24,"value":189},"'\u002Fapi\u002Fposts'",{"type":18,"tag":44,"props":191,"children":192},{"style":57},[193],{"type":24,"value":137},{"type":18,"tag":44,"props":195,"children":196},{"style":104},[197],{"type":24,"value":142},{"type":18,"tag":44,"props":199,"children":200},{"style":57},[201],{"type":24,"value":126},{"type":18,"tag":44,"props":203,"children":204},{"style":149},[205],{"type":24,"value":152},{"type":18,"tag":44,"props":207,"children":208},{"style":51},[209],{"type":24,"value":157},{"type":18,"tag":44,"props":211,"children":212},{"style":57},[213],{"type":24,"value":162},{"type":18,"tag":44,"props":215,"children":216},{"style":104},[217],{"type":24,"value":167},{"type":18,"tag":44,"props":219,"children":220},{"style":57},[221],{"type":24,"value":172},{"type":18,"tag":44,"props":223,"children":225},{"class":46,"line":224},4,[226],{"type":18,"tag":44,"props":227,"children":228},{"style":57},[229],{"type":24,"value":230},"])\n",{"type":18,"tag":19,"props":232,"children":234},{"id":233},"promiseallsettled",[235],{"type":24,"value":236},"Promise.allSettled",{"type":18,"tag":27,"props":238,"children":239},{},[240],{"type":24,"value":241},"Wait for all promises regardless of outcome:",{"type":18,"tag":33,"props":243,"children":245},{"className":35,"code":244,"language":37,"meta":7,"style":7},"const results = await Promise.allSettled([\n  fetch('\u002Fapi\u002Ffast'),\n  fetch('\u002Fapi\u002Fslow'),\n  fetch('\u002Fapi\u002Ffailing'),\n])\n\nconst successful = results\n  .filter(r => r.status === 'fulfilled')\n  .map(r => r.value)\n",[246],{"type":18,"tag":40,"props":247,"children":248},{"__ignoreMap":7},[249,287,308,328,348,356,366,388,434],{"type":18,"tag":44,"props":250,"children":251},{"class":46,"line":47},[252,256,261,266,270,274,278,283],{"type":18,"tag":44,"props":253,"children":254},{"style":51},[255],{"type":24,"value":54},{"type":18,"tag":44,"props":257,"children":258},{"style":63},[259],{"type":24,"value":260}," results",{"type":18,"tag":44,"props":262,"children":263},{"style":51},[264],{"type":24,"value":265}," =",{"type":18,"tag":44,"props":267,"children":268},{"style":51},[269],{"type":24,"value":91},{"type":18,"tag":44,"props":271,"children":272},{"style":63},[273],{"type":24,"value":96},{"type":18,"tag":44,"props":275,"children":276},{"style":57},[277],{"type":24,"value":101},{"type":18,"tag":44,"props":279,"children":280},{"style":104},[281],{"type":24,"value":282},"allSettled",{"type":18,"tag":44,"props":284,"children":285},{"style":57},[286],{"type":24,"value":112},{"type":18,"tag":44,"props":288,"children":289},{"class":46,"line":115},[290,294,298,303],{"type":18,"tag":44,"props":291,"children":292},{"style":104},[293],{"type":24,"value":121},{"type":18,"tag":44,"props":295,"children":296},{"style":57},[297],{"type":24,"value":126},{"type":18,"tag":44,"props":299,"children":300},{"style":129},[301],{"type":24,"value":302},"'\u002Fapi\u002Ffast'",{"type":18,"tag":44,"props":304,"children":305},{"style":57},[306],{"type":24,"value":307},"),\n",{"type":18,"tag":44,"props":309,"children":310},{"class":46,"line":175},[311,315,319,324],{"type":18,"tag":44,"props":312,"children":313},{"style":104},[314],{"type":24,"value":121},{"type":18,"tag":44,"props":316,"children":317},{"style":57},[318],{"type":24,"value":126},{"type":18,"tag":44,"props":320,"children":321},{"style":129},[322],{"type":24,"value":323},"'\u002Fapi\u002Fslow'",{"type":18,"tag":44,"props":325,"children":326},{"style":57},[327],{"type":24,"value":307},{"type":18,"tag":44,"props":329,"children":330},{"class":46,"line":224},[331,335,339,344],{"type":18,"tag":44,"props":332,"children":333},{"style":104},[334],{"type":24,"value":121},{"type":18,"tag":44,"props":336,"children":337},{"style":57},[338],{"type":24,"value":126},{"type":18,"tag":44,"props":340,"children":341},{"style":129},[342],{"type":24,"value":343},"'\u002Fapi\u002Ffailing'",{"type":18,"tag":44,"props":345,"children":346},{"style":57},[347],{"type":24,"value":307},{"type":18,"tag":44,"props":349,"children":351},{"class":46,"line":350},5,[352],{"type":18,"tag":44,"props":353,"children":354},{"style":57},[355],{"type":24,"value":230},{"type":18,"tag":44,"props":357,"children":359},{"class":46,"line":358},6,[360],{"type":18,"tag":44,"props":361,"children":363},{"emptyLinePlaceholder":362},true,[364],{"type":24,"value":365},"\n",{"type":18,"tag":44,"props":367,"children":369},{"class":46,"line":368},7,[370,374,379,383],{"type":18,"tag":44,"props":371,"children":372},{"style":51},[373],{"type":24,"value":54},{"type":18,"tag":44,"props":375,"children":376},{"style":63},[377],{"type":24,"value":378}," successful",{"type":18,"tag":44,"props":380,"children":381},{"style":51},[382],{"type":24,"value":265},{"type":18,"tag":44,"props":384,"children":385},{"style":57},[386],{"type":24,"value":387}," results\n",{"type":18,"tag":44,"props":389,"children":391},{"class":46,"line":390},8,[392,397,402,406,410,414,419,424,429],{"type":18,"tag":44,"props":393,"children":394},{"style":57},[395],{"type":24,"value":396},"  .",{"type":18,"tag":44,"props":398,"children":399},{"style":104},[400],{"type":24,"value":401},"filter",{"type":18,"tag":44,"props":403,"children":404},{"style":57},[405],{"type":24,"value":126},{"type":18,"tag":44,"props":407,"children":408},{"style":149},[409],{"type":24,"value":152},{"type":18,"tag":44,"props":411,"children":412},{"style":51},[413],{"type":24,"value":157},{"type":18,"tag":44,"props":415,"children":416},{"style":57},[417],{"type":24,"value":418}," r.status ",{"type":18,"tag":44,"props":420,"children":421},{"style":51},[422],{"type":24,"value":423},"===",{"type":18,"tag":44,"props":425,"children":426},{"style":129},[427],{"type":24,"value":428}," 'fulfilled'",{"type":18,"tag":44,"props":430,"children":431},{"style":57},[432],{"type":24,"value":433},")\n",{"type":18,"tag":44,"props":435,"children":437},{"class":46,"line":436},9,[438,442,447,451,455,459],{"type":18,"tag":44,"props":439,"children":440},{"style":57},[441],{"type":24,"value":396},{"type":18,"tag":44,"props":443,"children":444},{"style":104},[445],{"type":24,"value":446},"map",{"type":18,"tag":44,"props":448,"children":449},{"style":57},[450],{"type":24,"value":126},{"type":18,"tag":44,"props":452,"children":453},{"style":149},[454],{"type":24,"value":152},{"type":18,"tag":44,"props":456,"children":457},{"style":51},[458],{"type":24,"value":157},{"type":18,"tag":44,"props":460,"children":461},{"style":57},[462],{"type":24,"value":463}," r.value)\n",{"type":18,"tag":465,"props":466,"children":467},"style",{},[468],{"type":24,"value":469},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":175,"depth":175,"links":471},[472,473],{"id":21,"depth":115,"text":25},{"id":233,"depth":115,"text":236},"markdown","content:javascript:promises.md","content","javascript\u002Fpromises.md","javascript\u002Fpromises","md",[481,490,495,501,506,511,516,521,526,535,540,545,550,555,560,565,571,578],{"_path":482,"title":483,"description":484,"tags":485,"date":489},"\u002Fcompetitive-programming\u002Farray-manipulation\u002Ffor-looping","For Looping in Python","Using for loops to manipulate arrays in Python.",[486,487,488],"python","backend","arrays","2026-03-18",{"_path":491,"title":492,"description":493,"tags":494,"date":489},"\u002Fcompetitive-programming\u002Farray-manipulation\u002Fwhile-looping","While Looping in Python","Using while loops to manipulate arrays in Python.",[486,487,488],{"_path":496,"title":497,"description":498,"tags":499,"date":500},"\u002Fcompetitive-programming\u002Fassignments","Assignments","Assignments in Python for competitive programming.",[486,487],"2026-04-10",{"_path":502,"title":503,"description":504,"tags":505,"date":500},"\u002Fcompetitive-programming\u002Fdata-type","Data Types","Data types in Python for competitive programming.",[486,487],{"_path":507,"title":508,"description":509,"tags":510,"date":500},"\u002Fcompetitive-programming\u002Fhash-map","Hash Map","Hash map implementation in Python for competitive programming.",[486,487],{"_path":512,"title":513,"description":514,"tags":515,"date":500},"\u002Fcompetitive-programming\u002Finput-output","Input and Output","Handling input and output in Python for competitive programming.",[486,487],{"_path":517,"title":518,"description":519,"tags":520,"date":489},"\u002Fcompetitive-programming\u002Fmath-library\u002Fsum","Sum Elements","Using for loops to sum elements in Python.",[486,487,488],{"_path":522,"title":523,"description":524,"tags":525,"date":489},"\u002Fcompetitive-programming\u002Fmath-library\u002Fsummary","Summary","Summary of the math library in Python.",[486,487,488],{"_path":527,"title":528,"description":529,"tags":530,"date":534},"\u002Fdocker\u002Fcheat-sheets","Docker Cheat Sheets","Cheat sheets for frequently used Docker commands and concepts",[531,532,533],"docker","devops","infrastructure","2026-05-01",{"_path":536,"title":537,"description":538,"tags":539,"date":13},"\u002Fdocker\u002Fdocker-dasar\u002Fdocker-container","Docker Container","Introduction to Docker containers and their usage",[531,532,533],{"_path":541,"title":542,"description":543,"tags":544,"date":13},"\u002Fdocker\u002Fdocker-dasar\u002Fdocker-execution","Docker Execution","Introduction to Docker execution and their usage",[531,532,533],{"_path":546,"title":547,"description":548,"tags":549,"date":13},"\u002Fdocker\u002Fdocker-dasar\u002Fdocker-image","Docker Image","Introduction to Docker images and their usage",[531,532,533],{"_path":551,"title":552,"description":553,"tags":554,"date":13},"\u002Fdocker\u002Fdocker-dasar\u002Fdocker-logging","Docker Logging","Introduction to Docker logging and their usage",[531,532,533],{"_path":556,"title":557,"description":558,"tags":559,"date":13},"\u002Fdocker\u002Fdocker-prerequisites\u002Fdocker-installation","Docker Installation","Introduction to Docker installation and their usage",[531,532,533],{"_path":561,"title":562,"description":563,"tags":564,"date":13},"\u002Fdocker\u002Fresources","Docker Resources","Collection of Docker resources for learning and reference",[531,532,533],{"_path":566,"title":567,"description":568,"tags":569,"date":489},"\u002Fphp\u002Farrays","PHP Array Functions","Essential PHP array functions and patterns",[570,487,488],"php",{"_path":572,"title":573,"description":574,"tags":575,"date":577},"\u002Fphp\u002Fpatterns\u002Fsingleton","Singleton Pattern","Implementing the singleton pattern in PHP",[570,576,487],"patterns","2026-03-13",{"_path":579,"title":580,"description":581,"tags":582,"date":583},"\u002Fphp\u002Freferences","PHP References (&)","Useful PHP reference snippets and patterns",[570,487],"2026-03-19",[585,587,588,589,590,591,592,594,595,597,598,600,602,604,605,606,607,608,609],{"_path":482,"title":483,"weight":586},10,{"_path":491,"title":492,"weight":586},{"_path":496,"title":497,"weight":175},{"_path":502,"title":503,"weight":115},{"_path":507,"title":508,"weight":586},{"_path":512,"title":513,"weight":47},{"_path":517,"title":518,"weight":593},20,{"_path":522,"title":523,"weight":586},{"_path":527,"title":528,"weight":596},100,{"_path":536,"title":537,"weight":593},{"_path":541,"title":542,"weight":599},22,{"_path":546,"title":547,"weight":601},21,{"_path":551,"title":552,"weight":603},23,{"_path":556,"title":557,"weight":586},{"_path":561,"title":562,"weight":47},{"_path":4,"title":8},{"_path":566,"title":567,"weight":47},{"_path":572,"title":573},{"_path":579,"title":580,"weight":115},1777665108262]