axios post json site:stackoverflow.com code example

Example: axios get request javascript stackoverflow

constructor(props) {
        super(props);
        this.state = {
            clients: [],
            Code: props.match.params.Code
        };
componentDidMount() {
        axios.get('http://localhost:4000/app/viewclient/' + this.props.match.params.Code).then(function(response) {
            if (response.status >= 400) {
                throw new Error("Bad response from server");
            }
            return response.json();
        }).then(function(data) {
            if (data === "success") {
                this.setState({ msg: "User has been deleted." });
            }
        }).catch(function(err) {
            console.log(err)
        });
    }