Answers for "axios try catch get status code"

11

axios try catch get error status cocxe

try {
     	await axios.get('/bad-call')
     } catch (error) {
        const err = error as AxiosError
        if (err.response) {
           console.log(err.response.status)
           console.log(err.response.data)
        }
        this.handleAxiosError(error)
     }
Posted by: Guest on May-24-2020
2

vue axios catch error

axios.get('/user/1').then((response) => {
    console.log('Everything is awesome.');
}).catch((error) => {
    console.warn('Not good man :(');
})
Posted by: Guest on April-24-2020
0

axios 200 goes into then and catch

this issue happen when your response have an error , for example when the response is correct but in the then response you do something that throw an error , axios then catch that error , even if the response from the server was success
Posted by: Guest on June-30-2021
0

axios try catch get status code

catch (error) {
    if ((error as AxiosError).response?.status === 404) {
      setJobListError('Error type 404'))
    }
Posted by: Guest on October-22-2021

Code answers related to "axios try catch get status code"

Code answers related to "Javascript"

Browse Popular Code Answers by Language