Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GodziLaravel's avatar

Axios: Uncaught (in promise) TypeError: Cannot read property 'status' of undefined

Hello ,

When I use axios to create a model I have this error message ?

Uncaught (in promise) TypeError: Cannot read property 'status' of undefined

Here my code :

            createTask() {
                let newTask = this.$refs.addNewTaskData.newTask;
                axios.post('/api/tasks',
                    newTask
                )
                    .then((response) => {
                        //console.log(response.data);
                        this.$refs.closeAddModal.click();
                        this.taskCreatedConfirmation();
                        this.showTaskEdit(0);
                        this.$refs.dealTasksTable.refresh();

                    })
                    .catch(error => {
                        if (error.response.status === 422) {
                            this.$refs.addNewTaskData.errors = error.response.data.errors;
                        }

                    });


            },
0 likes
2 replies
munazzil's avatar

After the this newTask you are using a close bracket) use an open bracket (.

mdl's avatar

As your XHR returns an error, could you console.log the error object to see it's structure?

Your above mentioned error comes from error.response.status being undefined, as status does not exist in response.

Check this comment on some issue on Github for Axios that sounds close to your problem: https://github.com/axios/axios/issues/960#issuecomment-342661087

So possible that your endpoint is returning you a 500 and Axios can't handle the Error.

Please or to participate in this conversation.