0

I ask the help of knowledgeable people im create a RESTfull API project on Vue.js (Vuex also) And im get small problem The server to which I am sending the request is down why how idn Can someone tell me how can im detect this message from response enter image description here

enter image description here

This response dont have any massege, error, status, statusText, text, preview and response All this field is empty If someone have expirience about this or some info I will be very grateful for that

1 Answer 1

1

You can do something like this to handle these cases:

submitRequest() {
  axios.post('/api/test', this.testData)
    .then(response => {
      // handle success
    })
    .catch(function(error) {
      // handle error
      if (error.response) {
        // The request was made and the server responded with a status code
      } else if (error.request) {
        // YOU CAN HANDLE IT HERE
        // The request was made but no response was received
        // `error.request` is an instance of XMLHttpRequest in the browser
        console.log(error.request);
      } else {
        // Something happened in setting up the request that triggered an Error
      }
    });
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.