search

Home  >  Q&A  >  body text

angular.js - angularjs-ngResource 强制要求返回数据为object

Error: [$resource:badcfg] Error in resource configuration for action query. Expected response to contain an array but got an object
query()方法要求服务端返回的是array类型,而我的后端返回的是一个对象(object)包含分页等数据,data成员才是post列表。
请问在不修改服务端的情况下如何解决这个问题?

天蓬老师天蓬老师2744 days ago554

reply all(3)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 16:55:15

    Done. Just add a parameter when instantiating the Post model. Wow hahaha

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-15 16:55:15

    You can rewrite the query method, I already told you in the QQ group today

    reply
    0
  • PHPz

    PHPz2017-05-15 16:55:15

    Isn’t it better to just use get?

    reply
    0
  • Cancelreply