Implementing in my @vue/cli 4.0.5 app vue-tables-2 component with server-table and looking at this https://matanya.gitbook.io/vue-tables-2/server-table/custom-request-function
I try to set additive Authorization parameter to request like:
<div id="activity_logs_data_table">
<v-server-table url="/adminarea/activity-logs-filter" :columns="columns" :options="tableOptions">
<span slot="edit" slot-scope="{row}">
<a v-on:click="viewActivityLog(row)" :class="'p-1 a_view_item_'+row.id">
<i :class="'i_link '+getHeaderIcon('view')" title="View activity log item"></i>
</a>
<a v-on:click="removeActivityLog(row.id, row.log_name)" :class="'p-1 a_delete_item_'+row.id">
<i :class="'i_link '+getHeaderIcon('remove')" title="Remove activity log item"></i>
</a>
</span>
<span slot="created_at" slot-scope="{row}">
{{ momentDatetime(row.created_at, jsMomentDatetimeFormat) }}
</span>
</v-server-table>
</div>
data() {
return {
activityLogs: [],
el: "#activity_logs_data_table",
columns: ['id', 'log_name', 'causer_id', 'causer_type', 'created_at', 'edit'],
tableOptions: {
requestFunction: (data) => {
console.log('requestFunction data::')
console.log(data)
this.is_page_loaded = false
this.credentialsConfig.headers.Authorization = 'Bearer ' + this.currentLoggedUserToken;
console.log('requestFunction this.credentialsConfig::')
console.log(this.credentialsConfig)
return axios.get(this.url, {
params: data
}, this.credentialsConfig ).catch(function (error) {
console.log('requestFunction error::')
console.error(error)
// this.dispatch('error', error );
});
} // requestFunction: (data) => {
But I see error in console :
TypeError: Cannot read property 'indexOf' of undefined
at buildURL (buildURL.js?30b5:62)
at dispatchXhrRequest (xhr.js?b50d:30)
at new Promise (<anonymous>)
at xhrAdapter (xhr.js?b50d:12)
at dispatchRequest (dispatchRequest.js?5270:52)
and printscreen of console with debugging : https://prnt.sc/rtak15 I see query parameter empty ... Could it be the issue? Are parameters in axios.get invalid ?
"axios": "^0.19.0",
"vue": "^2.6.10",
"vue-tables-2": "^2.0.14"
Thanks!
I managed to run request as:
requestFunction(data) {
let credentialsConfig= JSON.parse(JSON.stringify(settingCredentialsConfig))
credentialsConfig.headers.Authorization = 'Bearer ' + this.$parent.$parent.currentLoggedUserToken
return axios.get(this.url, {
params: data
}, credentialsConfig ).catch(function (error) {
console.error(error)
})
} // requestFunction: (data) => {
!