search

Home  >  Q&A  >  body text

angular.js - angularjs-ngResource forces the returned data to be object

Error: [$resource:badcfg] Error in resource configuration for action query. Expected response to contain an array but got an object
The query() method requires the server to return an array type, while my backend returns an object containing pagination and other data, and the data member is the post list.
How can I solve this problem without modifying the server?

天蓬老师天蓬老师2865 days ago594

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