Files
side-by-side/source/documents/scripts/services/fetch.js.coffee
T
2013-06-18 00:00:59 +01:00

17 lines
447 B
CoffeeScript

angular.module("sideBySide").factory "fetch", ['$http', 'readerFactory', ($http, readerFactory) ->
# Fetch
#
# @param file [String] Path to config file
# @return TODO
return (file = "config.json") ->
$http.get(file).then((response) ->
promises = []
for poem in response.data.files
promises.push($http.get(poem).then((response) ->
reader = readerFactory(poem)
return reader(response.data)
))
return promises
)
]