Helper endpoints for gamertag validation, user lookup, and payment requests
// ❌ Bad: Send and hope try { await sendReward({ gamertag: userInput, amount: 1000 }); } catch (error) { // Reward failed, bad user experience } // ✅ Good: Validate first const userId = await getUserIdByGamertag(userInput); if (userId) { await sendReward({ gamertag: userInput, amount: 1000 }); // Success guaranteed } else { showError("Invalid gamertag. Please check and try again."); }
// Monday: User is "bitcoinlover" database.save({ gamertag: "bitcoinlover", totalEarned: 5000 }); // Tuesday: User changes to "cryptoking" database.save({ gamertag: "cryptoking", totalEarned: 1000 }); // Now you have duplicate records! 😱
Was this page helpful?