Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
826 B
2
Indexable
Never
export function* fetchDownloadAttachmentInterviewResult(params) {
    try {
        yield put({ type: types.RECRUITMENT_PR_SET_LOADER, value: true })
        const response = yield call(axios.get, params.url, {
            responseType: 'arraybuffer' /** <-- responseType should be set to arraybuffer */
        })
        if (response.status === 200) {
            const blob = new Blob([response.data])
            const link = document.createElement('a')
            link.href = window.URL.createObjectURL(blob)
            link.download = params.fileName
            link.click()
            yield put({ type: types.RECRUITMENT_PR_SET_LOADER, value: false })
        }
    } catch (e) {
        yield put({ type: types.RECRUITMENT_PR_SET_LOADER, value: false })
        console.log('REASON', e)
    }
}