我的项目是使用brunch-with-chapling样板文件设置的,其中包含一些额外的库:
我遇到的问题是,当我尝试获取模型时,我的虚假服务器显示我已成功接收并回复已发出的请求。 Jet触发成功或错误功能。
这是我的提取代码:
Base(Shop)课程:
###
# Appends header to fetch request.
###
getModel: (id, obj)->
console.log "Requesting model #{@type} with id #{id}", 'model'
obj.url = "#{@urlRoot()}/#{id}"
@fetch obj
###
# Fetches models.
###
fetch: (options = {})=>
console.log options
options.headers ?= {}
options.headers.Authorization = Mediator.execute 'getAuth'
options.headers.Accept = 'application/json;charset=utf-8'
success = options.success
options.success = ->
console.log 'test'
success()
options.error = ->
console.log 'error'
super options
查看课程
initialize: (options = {})->
shopId = Mediator.execute 'getActiveShop'
if shopId is undefined
setTimeout (=>@initialize()), 50
return
@shop = new Shop
console.log @shop
@shop.accountId = (Mediator.execute 'getAccount').get 'id'
@shop.getModel shopId, {
success: =>
console.log 'test'
@render()
error: ((a,b,c)=> @publishEvent 'modelConnectionError', a,b,c)
}
super