riku
2024-10-24 71ed602a8b17430c119b2ae6472a47dd6e6e0c95
src/api/fytz/creditApi.js
@@ -1,3 +1,4 @@
import { Base64 } from 'js-base64';
import { $fytz } from '../index';
/**
@@ -12,10 +13,11 @@
    return $fytz
      .get(`credit/ecCode/download?userId=${userId}`, { responseType: 'blob' })
      .then((res) => {
        const url = window.URL.createObjectURL(new Blob([res.data]));
        const name = Base64.decode(res.headers.get('fileName'));
        const url = window.URL.createObjectURL(res.data);
        const link = document.createElement('a');
        link.href = url;
        link.setAttribute('download', 'creditCode.png');
        link.setAttribute('download', name);
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);