@@ -101,31 +101,6 @@ function serialiseRelation (node, nodeType, key, data) {
101101 return data
102102}
103103
104- /**
105- * Serialises an array to JSON:API format
106- *
107- * @param {Object } node Resource object
108- * @param {string } nodeType Resource type of the object
109- * @param {string } key The resource object's key value
110- * @param {Object } data Root JSON:API data object
111- * @private
112- */
113- function serialiseArray ( node , nodeType , key , data ) {
114- if ( ! data . relationships ) data . relationships = { }
115-
116- data . relationships [ key ] = {
117- data : node . data . map ( ( { id, type, ...attributes } ) => {
118- return {
119- id,
120- type : type || nodeType ,
121- attributes : Object . keys ( attributes ) . length ? attributes : undefined
122- }
123- } )
124- }
125- data . relationships = serialiseRelation ( data . relationships )
126- return data
127- }
128-
129104/**
130105 * Serialises attributes to JSON:API format
131106 *
@@ -200,9 +175,7 @@ function serialiseRootObject (type, payload, method, options) {
200175 // 1. Skip null nodes, 2. Only grab objects, 3. Filter to only serialise relationable objects
201176 if ( node !== null && node ?. constructor === Object && hasID ( node ) ) {
202177 data = serialiseRelation ( node , nodeType , key , data )
203- // 1. Skip null nodes, 2. Only grab arrays, 3. Filter to only serialise relationable arrays
204- // } else if (node !== null && node?.constructor === Object && hasID(node)) {
205- // data = serialiseArray(node, nodeType, key, data)
178+
206179 // 1. Don't place id/key inside attributes object
207180 } else if ( key !== 'id' && key !== 'type' ) {
208181 data = serialiseAttr ( node , key , data )
0 commit comments