React JS Axios Post request 500 (Internal Server Error) code example

Example: POST http://localhost:5001/api/v1/identity/login 500 (Internal Server Error) LoginForm.jsx:30 Error: Request failed with status code 500 at createError (createError.js:16) at settle (settle.js:17) at XMLHttpRequest.handleLoad (xhr.js:61) react

axios.post(
            config.apiGateway.URL + ".../signin",
            payload
        ).then(response => {
            console.log(response)
            if(response.status == 200){
                console.log("Login successfull");
                this.setState({token: response.data.JWT_TOKEN});
            } else {
                console.log(response.status)
                this.setError()
            }
        }).catch(error => {
            this.setError()
            console.log(error)
            if (error.response) {
                console.log("--------------------------------------------------")
                // The request was made and the server responded with a status code
                // that falls out of the range of 2xx
                console.log(error.response.data);
                console.log(error.response.status);
                console.log(error.response.headers);
            } else if (error.request) {
                console.log("*************************")

                // The request was made but no response was received
                // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
                // http.ClientRequest in node.js
                console.log(error.request);
            } else {
                console.log("++++++++++++++++++++++++")
                // Something happened in setting up the request that triggered an Error
                console.log('Error', error.message);
            }
            console.log(error.config);
        })

Tags:

Html Example