“cara menangani kesalahan Axios JS” Kode Jawaban

cara menangani kesalahan Axios JS

axios.post("/api/end", {data : "xx"})
  .then(({ data }) => {
  // doing something with success
  })
  .catch((err) => {
  let message = typeof err.response !== "undefined" ? err.response.data.message : err.message;
  console.warn("error", message);
});
Indonesia People

Axios mendapatkan pesan kesalahan

  .catch(function (error) {
    if (error.response) {
      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);
    }
Sbeajy

penanganan kesalahan panggilan axios

axios.get('/api/xyz/abcd')
  .catch(function (error) {
    if (error.response) {
      // Request made and server responded
      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);
    } else if (error.request) {
      // The request was made but no response was received
      console.log(error.request);
    } else {
      // Something happened in setting up the request that triggered an Error
      console.log('Error', error.message);
    }

  });
Poised Penguin

Kesalahan Axios

axios.get('/api/xyz/abcd')
  .catch(function (error) {
    if (error.response) {
      // Request made and server responded
      console.log(error.response.data);
      console.log(error.response.status);
      console.log(error.response.headers);
    } else if (error.request) {
      // The request was made but no response was received
      console.log(error.request);
    } else {
      // Something happened in setting up the request that triggered an Error
      console.log('Error', error.message);
    }

  });
Zealous Zebra

Axios Cara Mendapatkan Respons Kesalahan

axios.post('/formulas/create', {
	name: "",
	parts: ""
})
.then(response => { 
	console.log(response)
})
.catch(error => {
    console.log(error.response)
});
Lonely Lapwing

Jawaban yang mirip dengan “cara menangani kesalahan Axios JS”

Pertanyaan yang mirip dengan “cara menangani kesalahan Axios JS”

Lebih banyak jawaban terkait untuk “cara menangani kesalahan Axios JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya