feat: Allow renderer to use explicitly defined serializers
This commit is contained in:
@@ -11,7 +11,7 @@ const isArray = (object) =>
|
|||||||
const totalCount = (object) =>
|
const totalCount = (object) =>
|
||||||
isPaginated(object) ? object.totalCount : isArray(object) ? object.length : 1;
|
isPaginated(object) ? object.totalCount : isArray(object) ? object.length : 1;
|
||||||
|
|
||||||
const renderObject = (response, object) => {
|
const renderObject = (response, object, options) => {
|
||||||
let data = isPaginated(object) ? object.records : object;
|
let data = isPaginated(object) ? object.records : object;
|
||||||
|
|
||||||
const type = isPaginated(object)
|
const type = isPaginated(object)
|
||||||
@@ -20,7 +20,9 @@ const renderObject = (response, object) => {
|
|||||||
? object?.[0]?.constructor?.name || 'Object'
|
? object?.[0]?.constructor?.name || 'Object'
|
||||||
: object.constructor.name;
|
: object.constructor.name;
|
||||||
|
|
||||||
const serializer = serializers[type];
|
const serializer = options?.serializer
|
||||||
|
? serializers[options.serializer]
|
||||||
|
: serializers[type];
|
||||||
|
|
||||||
if (serializer) {
|
if (serializer) {
|
||||||
data = Array.isArray(data)
|
data = Array.isArray(data)
|
||||||
|
Reference in New Issue
Block a user