vonPiernik
4/25/2018 - 3:49 PM

books.service.js

function uploadBook(files) {
    var data = new FormData()
    files.forEach(function(file){
        data.append('file[]', file)
    })
    const requestOptions = {
        method: 'POST',
        headers: authHeader(),
        body: data
    };
    return fetch(apiUrl + '/books', requestOptions)
        .then(handleResponse, handleError)
        .then(files => {
            return files;
        });
}