I have returning data like:
data: "C:\laragon\www\test\public\exports\20200501030547-Products.xlsx"
message: "Products are successfully exported."
I want to start download C:\laragon\www\test\public\exports\20200501030547-Products.xlsx
file automatically as it returns in success part.
axios.get( '/api/admin/products/export', {
headers: {
Authorization: localStorage.getItem('access_token')
}
}).then(res => {
console.log(res.data.data) // my file
this.$notify({
title: 'Hooray!',
message: res.data.message,
offset: 100,
type: 'success'
});
})
.catch(error => {
var errors = error.response.data;
let errorsHtml = '<ol>';
$.each(errors.errors,function (k,v) {
errorsHtml += '<li>'+ v + '</li>';
});
errorsHtml += '</ol>';
this.$notify.error({
title: 'Export Error',
dangerouslyUseHTMLString: true,
message: errorsHtml
});
});
Any idea?
Solution was using window.open('res.data.data', '_blank')
however if you use local data in chrome browser (as i am right now) it returns this error Not allowed to load local resource:
But I guess it shouldn't have any issue with production app in real server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.