reyesoft / ngx-jsonapi

JSON API client library for Angular 5+ 👌 :: Production Ready 🚀
https://ngx-jsonapi.reyesoft.com/
MIT License
101 stars 52 forks source link

TypeError: Cannot read property 'cachememory' of undefined #58

Closed sunel closed 6 years ago

sunel commented 6 years ago

i a, getting below error when calling the Service

TypeError: Cannot read property 'cachememory' of undefined
    at Function.webpackJsonp../node_modules/ngx-jsonapi/ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.es5.js.Converter._buildCollection (ngx-jsonapi.es5.js:1174)
    at Function.webpackJsonp../node_modules/ngx-jsonapi/ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.es5.js.Converter.build (ngx-jsonapi.es5.js:1148)
    at ngx-jsonapi.es5.js:2426
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:4749)
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
    at Zone.webpackJsonp../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
    at zone.js:858
    at ZoneDelegate.webpackJsonp../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:4740)
pablorsk commented 6 years ago

Hi! Can you share your controller?

This problem is when you get from server a resource or collection with a type not a service with the same resource type injected on controller.

    public constructor(
        protected authorsService: AuthorsService
    ) {
       authorsService.get(); // return a resrouce with type, for example, 'books', and book are not registered
    }