首页 > 解决方案 > 在 React 中提交登录时,我在 (Localhost)URL 中获取我的密码和电子邮件作为查询字符串吗?

问题描述

在 Localhost 中运行我的项目并提供我的登录信息后,我在我的 URL 中得到了这个

http://localhost:3000/?email-address=roopa%40gmail.com&password=roopa3

我还在我的活动中检查了“onClick”,但一切都很好..

    event.preventDefault();
    console.log('emailchanged')
    this.setState({signinEmail: event.target.value})
    }

    onPasswordchange = (event) => {
    event.preventDefault();
    console.log('passwordchanged')
    this.setState({signinPassword: event.target.value})
    }

    onSubmitSignin = () => {
        console.log('entered onsubmitsignin..') // after this console msg again my localhost redirects me to a new signin page which giving inputs to URL as query strings 
        fetch('http://localhost:8050/signinpage/', {
            method: 'post',
            headers: {'Content-Type': 'application/json'},
            body: JSON.stringify({
                email: this.state.signinEmail,
                password: this.state.signinPassword
            })
        })
        .then(function (response) {
                console.log(response.status);
                return response.json();
                })
        .then(res => {
            if(res.ok){
                this.props.onRoutechange('Home'); 
            }
            else if (!res.ok) {
                throw new Error("HTTP status " + res.status);
            }
        })
    } 

我不需要我的输入在这里显示为查询字符串..!

标签: reactjsreact-nativeexpressreact-reduxquery-string

解决方案


推荐阅读