Pathum
1 year ago
243
8
Vue

How to fix 500 and 429 errors with axios ?

Posted 1 year ago by Pathum

Currently i'm working on a project with Laravel and Vuejs, in almost every components does have http requets at mounted method, but some times when the page is loaded the data wont appear on the page. It happens when navigate through pages randomly, which every page does have http request in mounted method. Then it give these errors,

500 (Internal Server Error)

429 (Too Many Requests)

for example dashboard views mounted method looks like this,

mounted(){
        
        this.role = this.$store.getters.userRole;
       
        var userRole = this.$auth.getUserRole();


        axios.get('api/dashboard/getBonusesbyCustomers')
        .then( response =>{
            this.freeIssues = response.data
            console.log('freeIssues')
            console.log(this.freeIssues)
        }).catch( res =>{
            console.log(res)
        })
        axios.post('api/dashboard/getApprvalList')
        .then( response =>{
            this.appStock = response.data
            console.log(response)
        })

        axios.get('api/transactions/getItemsCount ')
        .then(response =>{
        //  console.log(response);
            this.items = response.data;
        })
     }

Please sign in or create an account to participate in this conversation.