Closed eduardmartinez closed 8 years ago
Well, I realized the problem was because all related resources weren't registered at app init. It means 'factory' (in the example) must be registered into $jsonapi or it will fail. It is not clear in the docs because it only says that register must be done in module's run() method but not why.
Glad you solved it! I'll improve the docs to make it more clear.
Moreover I'm working on moving 'registration' phase from module.run()
to module.config()
, to make it more logical.
I'm still experiencing this issue despite of running module definitions on initializers.
"use strict";
angular
.module("kelmat")
.run(initializer)
.factory("User", factoryConstructor);
function initializer($jsonapi, ENV) {
const
schema = {
type: "users",
attributes: {
email: {required: true},
firstName: {},
lastName: {},
externalAvatarUrl: {}
},
relationships: {
phoneNumbers: {
type: "hasOne",
model: "phoneNumbers",
reflection: false
}
}
},
url = ENV.API_URL + "/users",
restSource = $jsonapi.sourceRest.create("Rest source", url),
synchronizer = $jsonapi.synchronizerSimple.create([restSource]);
$jsonapi.addResource(schema, synchronizer);
}
function factoryConstructor($jsonapi, ENV) {
return $jsonapi.getResource("users");
}
Hi, again.
I was configuring my schema and making tests with 'include' option, having my schema with something like this:
Then, I execute resource's all() method, the request is made successfully and the server gives the results with 'data' and 'included' as JSON API spec says, but just right after that, this error appears:
What could the problem be?
Thanks in advance.
P.D.: Tested in Chrome.