mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-21 13:30:27 +08:00
18 lines
502 B
CoffeeScript
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
|
|
}
|
|
]
|