antos-frontend/src/core/apis/api.coffee

27 lines
700 B
CoffeeScript
Raw Normal View History

2017-08-07 00:49:24 +02:00
self.OS.API =
# the handler object could be a any remote or local handle to
# fetch user data, used by the API to make requests
# handlers are defined in /src/handlers
handler: new Object()
#request a user data
request: (query,callback) ->
# definition here
handle.request query,callback
systemConfig: ->
_API.request 'config', (result) ->
console.log result
2017-08-11 01:58:46 +02:00
get:(p,c)=>
$.get p
2017-08-07 00:49:24 +02:00
.done (data) ->
2017-08-11 01:58:46 +02:00
c(data)
2017-08-07 00:49:24 +02:00
.fail ->
alert "cannot get data"
2017-08-11 01:58:46 +02:00
c(null)
resource: (resource,callback) ->
path = "resources/#{resource}"
_API.get path,callback