UNPKG

game-library-sdk-mgs

Version:

SDK to integrate games with the game library platform.

27 lines (23 loc) 799 B
// session.js const reportGameSession = async (gameId, status) => { const token = localStorage.getItem("token"); if (!token) { alert("❌ لم يتم تسجيل الدخول!"); return; } const response = await fetch("http://localhost:3000/api/reportGameSession", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${token}`, }, body: JSON.stringify({ game_id: gameId, status }), }); const data = await response.json(); if (data.success) { alert("✅ تم إرسال حالة الجلسة!"); } else { alert("❌ فشل إرسال الحالة: " + data.error); } }; module.exports = { reportGameSession };