CSRF token mismatch Laravel Vue Axios

Viewed 107

I have a problem typing a data request to api. I use laravel vue and axios to make a request. the following problem appears

exception: "Symfony\Component\HttpKernel\Exception\HttpException" file: "/var/www/html/accurate/ibn_accurate_web_api/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php" line: 383 message: "CSRF token mismatch."

<script>
import axios from "axios"
// import pagination from 'laravel-vue-pagination'
export default {
    name: "branch-list",
    components: {
        // pagination
    },
    data() {
        return {
            branch: {
                type: Object,
                default: null
            }
        }
    },
    mounted() {
        this.list()
    },
    methods: {
        async list(page = 1) {
            await axios.post("http://ibn.tes/api/accurate/branch", {
                code_database: 550724,
                headers:{
                    "X-CSRF-TOKEN": window.Laravel.csrfToken
                }
            }).then(({ data }) => {
                this.branch = data
                console.log(data);
            }).catch(({ response }) => {
                console.error(response)
            })
        }
    }
}
</script>
0 Answers
Related