Home How to show dialog after successfull API call in react?
Reply: 0

How to show dialog after successfull API call in react?

user2223
1#
user2223 Published in May 21, 2018, 12:52 pm

I am having a button for signup

<button type="submit" className="btn btn-primary btn-blue login_btn" onClick={this.signup.bind(this)} data-toggle="modal" data-target="#signupdialog">Signup</button>

signup() {
    let data = Object.assign({}, this.state);
    UserAction._createUser(data);
}
}


export function _createUser(data) {
dispatcher.dispatch({
    type: 'Loader',
    showLoader: true
})
data = JSON.stringify(data);
let url = "/users/create";
let BASE = "http://172.104.167.150:9080"
let actualurl = BASE + url;

Api._callAPI(actualurl, 'POST', data, (type, dt) => {
    if (type == 'success') {
        dispatcher.dispatch({
            type: 'Loader',
            showLoader: false
        })
        dispatcher.dispatch({
            type: 'SnackBar',
            string: dt.response
        })
        }

});
}



<div className="modal fade" id="signupdialog" role="dialog">
            <div className="modal-dialog">


            <div className="modal-content">
                    <div className="modal-header" style={{backgroundColor: "#a8dde4"}}>
                    <button type="button" className="close" data-dismiss="modal">&times;</button>
                    <h4 className="modal-title">Hello !!</h4>
                    </div>
                    <div className="modal-body">
                    <p> Login Credentials has been sent to Email </p>

                    </div>
                    <div className="modal-footer">
                    <Link to="/" type="button" className="btn btn-default" style={{backgroundColor: "#a8dde4"}} data-dismiss="modal">Close</Link>
                    </div>
            </div>

            </div>
        </div>

I want on click on signup model to be shown after successful api call Now, AFter failure case of API also the model is coming on click on signup i want that model to be coming only after successfull Api call

Please Anyone guide me, of getting model after successfull action call instead of coming model all the time(in failure and success case)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.387835 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO