const consultarSaldo = async () => setLoading(true); const res = await fetch("/api/saldo/consulta", method: "POST", headers: "Content-Type": "application/json" , body: JSON.stringify( phoneNumber: phone ) ); const data = await res.json(); setSaldo(data); setLoading(false); ;
module.exports = getSaldo, recarga ; // routes/saldoRoutes.js const express = require("express"); const getSaldo, recarga = require("../services/telcelService"); const router = express.Router(); router.post("/consulta", (req, res) => const phoneNumber = req.body; const result = getSaldo(phoneNumber); res.json(result); ); saldo telcel
module.exports = router; When a user dials *133# on Telcel, they see a menu. Simulate it: const consultarSaldo = async () =>
// SaldoTelcel.jsx import useState from "react"; export default function SaldoTelcel() const [phone, setPhone] = useState(""); const [saldo, setSaldo] = useState(null); const [loading, setLoading] = useState(false); const res = await fetch("/api/saldo/consulta"