mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-21 13:30:27 +08:00
21 lines
509 B
CoffeeScript
21 lines
509 B
CoffeeScript
angular.module("sideBySide").factory "fetch", ['$http', 'readerFactory', ($http, readerFactory) ->
|
|
# Fetch
|
|
#
|
|
# @param file [String] Path to config file
|
|
# @return [Object] Promises and heading
|
|
(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)
|
|
reader(response.data)
|
|
))
|
|
|
|
{
|
|
promises: promises
|
|
heading: response.data.heading
|
|
}
|
|
)
|
|
]
|