Closed BlairAllegroTech closed 7 years ago
Though this implementation works i don't know if it is the best approach. What do you think. Feedback appreciated!!
I've found an issue with this test: https://github.com/BlairAllegroTech/js-data-jsonapi/blob/d67ff61c7dff78257b416927d23e1c32c87a76e0/src/JsonApiSerializer.ts#L936
if (relationship.data) {
In JavaScript an empty array is true.
> Boolean([]);
true
I think you need to make the test be:
if (relationship.data.length) {
Something in the code makes all relationships have an empty data array. Maybe this code?
function JsonApiRelationship() {
this.links = {};
this.data = new Array();
}
Are you saying that the many to many tests fail on your system or that your combination of js-data configuration and jsonApi data coming back from the server is failing?
If it is your setup that is failing, could you send me your js-data resource configuration and a copy of the response from your server so that i can test / debug this.
If it is the tests that are failing which browser and version are you running in ?
Thanks
This code after the test causes an issue for me:
var childRelationType = DSUTILS.isArray(relationship.data) ? relationship.data[0].type : (<JsonApi.JsonApiData>(<any>relationship.data)).type;
Because if relationship.data
is []
then relationship.data[0].type
raises an error.
First working version submitted. Requires some documentation on the Wiki pages