Created
March 1, 2017 19:54
-
-
Save lukaspili/9b0bca3a93b3c402980678c3817d6b17 to your computer and use it in GitHub Desktop.
audio_api mock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import client from './client' | |
export default { | |
loadList(page) { | |
console.log(`load audio books [page ${page}]`) | |
return client.get(`audio`, { page: page, per_page: 25 }) | |
.then(response => { | |
console.log(`load audio books success: [${response.data.books.length}]`); | |
return Promise.resolve(response.data.books) | |
}) | |
.catch(error => { | |
// return temporary mock data, until API is ready | |
return Promise.resolve([ | |
{ | |
id: 1, | |
name: 'book 1', | |
duration: 150, | |
data: 'http://www.stephaniequinn.com/Music/Allegro%20from%20Duet%20in%20C%20Major.mp3', | |
}, | |
{ | |
id: 2, | |
name: 'book 2', | |
duration: 110, | |
data: 'http://www.stephaniequinn.com/Music/Canon.mp3', | |
}, | |
]) | |
}) | |
}, | |
cancelLoadList() { | |
client.cancelRequest(`audio`) | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment