php - Laravel + Vue Application error with undefined function csfr_token()
working with Laravel and Vue js Application. and I have following welcome.blade.php file script in head tag
<script>
(function () {
window.Laravel = {
csrfToken: '{{ csfr_token() }}'
};
})();
</script>
and try to upload image in category.vue file as following
<Modal
v-model="addModal"
title="Add Category"
:mask-closable="false"
:closable="false"
>
<Input v-model="data.tagName" placeholder="Add Category Name" style="width: 300px" />
<div class="space"></div>
<Upload
type="drag"
:headers="{'x-csrf-token' : token}"
action="/app/upload">
<div style="padding: 20px 0">
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
<p>Click or drag files here to upload</p>
</div>
</Upload>
<div slot="footer">
<Button type="default" @click="addModal">Close</Button>
<Button type="primary" @click="addTag" :disabled="isAdding" :loading="isAdding">{{isAdding ? 'Adding..' : 'Add Tag'}}</Button>
</div>
</Modal>
but when run the program it is generating following error message
Symfony\Component\Debug\Exception\FatalThrowableError Call to undefined function csfr_token() (View: F:\2021 Technics\vue + laravel\fullstack\resources\views\welcome.blade.php)
how to fix this problem?
Answer
Solution:
Spelling mistake. Currect function name is
<script>
(function () {
window.Laravel = {
csrfToken: '{{ csrf_token() }}'
};
})();
</script>
Source