我想知道如何在执行REST API函数后传递值,而无需在MONGDB中存储数据



我从用户获取详细信息,并调用REST API功能并验证该详细信息。但是之后,我需要将所有详细信息传递给付款页面,而无需在我的mongodb中存储值。付款成功后,需要存储这些细节。

我正在使用React和HTML实施前端。我将电话号码和身份证号码视为有价值的数据。当我按提交按钮时,系统将验证用户并在下一页显示输出。我想将电话号码和身份证号码传递给下一页,而无需将其存储在mongodb中。

render() {
    return <div className="container card">
        <div className="card-body">
            <h4 className="card-title">Buyer Details</h4>
            <h6 className="card-subtitle mb-2 text-muted">We offer a discount for Government Employees by using your NIC number </h6><br/>
        <form>
            <div className="row">
                <div className="col-md-4 form-group">
                    <label htmlFor="name">First Name*</label>
                    <input type="text" className="form-control" id="fname" maxLength={100} placeholder="First Name" required/>
                </div>
                <div className="col-md-4 form-group">
                    <label htmlFor="name">Last Name*</label>
                    <input type="text" className="form-control" id="lname" maxLength={100} placeholder="Last Name" required/>
                </div>
            </div>
            <div className="row">
            <div className="col-md-4 form-group">
                <label htmlFor="telephone">Telephone*</label>
                <input type="tel" className="form-control" id="telephone" maxLength={10} minLength={10} placeholder="Your telephone number" required/>
            </div>
            <div className="col-md-4 form-group">
                <label htmlFor="telephone">Email*</label>
                <input type="email" className="form-control" id="telephone" placeholder="myemail@example.com" required/>
            </div>
            </div>
            <div className="row">
            <div className="form-group col-md-8">
                <label htmlFor="address">Address*</label>
                <input type="text" className="form-control" id="address1"
                       placeholder="Address Line 1 " required/><br/>
                <input type="text" className="form-control" id="address2" placeholder="City" required/>
            </div>
            </div>
            <div className="row">
                <div className="form-group col-md-4">
                    <label htmlFor="address">Gender*</label>
                    <select className="custom-select" required>
                        <option value="">--</option>
                        <option value="1">Male</option>
                        <option value="2">Female</option>
                    </select>
                </div>
                <div className="col-md-4 form-group">
                    <label htmlFor="telephone">NIC no*</label>
                    <input type="text" className="form-control" id="telephone" maxLength={10} minLength={10} placeholder="XXXXXXXXXV" required/>
                </div>
            </div>
            <div className="row">
                <div className="form-group col-md-4">
                <label htmlFor="telephone">Fields with * are required</label>
                </div>
            </div>
            <button type="submit" className="btn btn-info">Proceed</button>

        </form>
        </div>

    </div>;
}

我认为您正在后端部分进行反图案。您为什么不想将交易保存在MongoDB中?您在数据库上创建交易记录;然后在您的付款页面回调中,您将交易状态更新为已完成或失败。
这与反应或前端无关。

如果您使用的是诸如redux之类的中央商店,则可以更新状态。并再次将其放入下一页。否则,您可以将其保留在浏览器会话存储中并回收。

最新更新