请求URL太长返回错误414



我正在使用vuejs,并向服务器发出axios请求下载csv文件。

download() {
var that = this
//this.records = [{id: 1, name: 'Jack'}, {id: 2, name: 'Jacky'}, {id: 3, name: 'Jackie'}.....100s]
//this.header = [{value: 'id', text: 'ID'}, {value: 'name', text: 'Name'}]
var headers = this.header.map(a => a.text);
var url = USERS_REPORT_DOWNLOAD_URL + '?';
this.$axios.get(url, { params: { users: this.records, headers: headers}, responseType: 'blob' })
.then(response => {
var file = new Blob([response.data]);
FileSaver.saveAs(file, 'users ' + moment().format('MMMM Do YYYY, hh-mm a') + '.xls');
});
}

当这个方法被调用时,它返回HTTP Error 414 - The request URL is too long。也许是因为参数太长了。请帮我解决这个问题。

download() {
var that = this
//this.records = [{id: 1, name: 'Jack'}, {id: 2, name: 'Jacky'}, {id: 3, name: 'Jackie'}.....100s]
//this.header = [{value: 'id', text: 'ID'}, {value: 'name', text: 'Name'}]
var headers = this.header.map(a => a.text);
var url = USERS_REPORT_DOWNLOAD_URL + '?';
let postConfig = {
responseType: 'blob',
}
this.$axios.post(url, { users: this.records, headers: headers }, postConfig)
.then(response => {
var file = new Blob([response.data]);
FileSaver.saveAs(file, 'users ' + moment().format('MMMM Do YYYY, hh-mm a') + '.xls');
});
}

最新更新