AyanUpadhaya

Promise.all Example in JavaScript

Feb 10th, 2026
42
0
Never
6
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.98 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <title>Promise.all Example</title>
  5. </head>
  6. <body>
  7.  
  8.     <button id="fetchBtn">Fetch Data</button>
  9.     <div id="output">Click the button to load data...</div>
  10.  
  11.     <script>
  12.         const btn = document.getElementById('fetchBtn');
  13.         const output = document.getElementById('output');
  14.  
  15.         // The function triggered by the event
  16.         async function handleLoadData() {
  17.             output.innerHTML = "Loading...";
  18.  
  19.             // Define the API endpoints
  20.             const userUrl = 'https://jsonplaceholder.typicode.com/users/1';
  21.             const postsUrl = 'https://jsonplaceholder.typicode.com/posts?userId=1';
  22.  
  23.             try {
  24.                 // 1. Start both fetches at the same time
  25.                 // Promise.all wraps them into a single promise
  26.                 const [userResponse, postsResponse] = await Promise.all([
  27.                     fetch(userUrl),
  28.                     fetch(postsUrl)
  29.                 ]);
  30.  
  31.                 // 2. Parse both responses as JSON in parallel
  32.                 const [userData, postsData] = await Promise.all([
  33.                     userResponse.json(),
  34.                     postsResponse.json()
  35.                 ]);
  36.  
  37.                 // 3. Update the UI with both sets of data
  38.                 output.innerHTML = `
  39.                     <h3>User: ${userData.name}</h3>
  40.                     <p>Email: ${userData.email}</p>
  41.                     <h4>Recent Posts:</h4>
  42.                     <ul>
  43.                         ${postsData.map(post => `<li>${post.title}</li>`).join('')}
  44.                     </ul>
  45.                 `;
  46.  
  47.             } catch (error) {
  48.                 // If ANY of the requests fail, it will land here
  49.                 output.innerHTML = "Error loading data: " + error.message;
  50.                 console.error("Request failed", error);
  51.             }
  52.         }
  53.  
  54.         // Single Event Listener
  55.         btn.addEventListener('click', handleLoadData);
  56.     </script>
  57. </body>
  58. </html>
Advertisement
Comments
  • Texaslir
    93 days
    # CSS 0.84 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment