@@ -172,7 +172,7 @@ function jsonapify(data, model, selfUrl, context) {
172172 const idAttribute = Object . keys ( model . attributes ) . filter ( byPrimaryKey ( model ) ) [ 0 ] ;
173173 const excluded = [ idAttribute ] ;
174174
175- if ( context . include && context . include . length ) {
175+ if ( context && context . include && context . include . length ) {
176176 context . include . forEach ( parseRelationships ( data , includedData , model , selfUrl ) ) ;
177177 }
178178
@@ -295,7 +295,7 @@ function jsonapifyViaFind(hook, options) {
295295 if ( mustParseAsSequelize ( hook ) ) {
296296 hook . result . included = [ ] ;
297297 hook . result . data . forEach ( function ( data , index ) {
298- const jsonItem = data . toJSON ( ) ;
298+ const jsonItem = data ;
299299 serialized = jsonapify ( jsonItem , hook . service . Model , hook . path + '/' + jsonItem . id , data . $options ) ;
300300 hook . result . data [ index ] = serialized . document ;
301301 if ( serialized . related ) {
@@ -337,7 +337,7 @@ function jsonapifyViaFind(hook, options) {
337337function jsonapifyViaGet ( hook , options ) {
338338 let serialized = { } ;
339339 if ( mustParseAsSequelize ( hook ) ) {
340- const jsonItem = hook . result . toJSON ( ) ;
340+ const jsonItem = hook . result ;
341341 serialized = jsonapify ( jsonItem , hook . service . Model , hook . path + '/' + jsonItem . id , hook . result . $options ) ;
342342 hook . result = { data : serialized . document , included : serialized . related } ;
343343 if ( hook . result . included && ! hook . result . included . length ) {
0 commit comments