Files
side-by-side/source/scripts/services/fetch.js.coffee
T

18 lines
502 B
CoffeeScript

angular.module("sideBySide").factory "fetch", ['$http', '$q', 'readerFactory', ($http, $q, readerFactory) ->
# Fetch
#
# @param file [String] Path to config file
# @return [Object] Promises and heading
(file = "/config.json") ->
$http.get(file).then (config) ->
promises = config.data.files.map (poem) ->
$http.get(poem).then (response) ->
readerFactory(poem) response.data
{
fetchPoems: $q.all promises
heading: config.data.heading
active: config.data.active
}
]