JS. Как получить бинарный файл через fetch

JS. Как получить бинарный файл через fetch?


Ответы (1 шт):

Автор решения: Aziz Umarov

Можно так

fetch(path)
    .then(response => { 
        if (!response.ok) {
            throw new Error(`HTTP ${response.status} - ${response.statusText}`);
        }
        return response.arrayBufferr();})
    .then(buffer => {
       console.log(buffer);
       ....
    })
    .catch(err => console.error(err)); 
→ Ссылка