Skip to content

Commit

Permalink
Merge pull request #31 from arcataroger/patch-1
Browse files Browse the repository at this point in the history
Fix serializeRequestBody() body.type vs options.type parsing
  • Loading branch information
stefanoverna authored Oct 30, 2024
2 parents 38490df + f17465b commit a441002
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/rest-client-utils/src/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function serializeRequestBody<T extends { data: unknown } | null>(
} as unknown as T;
}

const { id, type, meta, ...otherProperties } = body as any;
const { id, meta, ...otherProperties } = body as any;

const attributes: Record<string, unknown> = {};
const relationships: Record<string, unknown> = {};
Expand Down Expand Up @@ -116,7 +116,7 @@ export function serializeRequestBody<T extends { data: unknown } | null>(
return {
data: {
...(id || options.id ? { id: id || options.id } : {}),
type: type || options.type,
type: options.type, // If a body.type is passed in, it should go in data.attributes. Only options.type should be here at the root.
...(Object.keys(attributes).length > 0 ? { attributes } : {}),
...(Object.keys(relationships).length > 0 ? { relationships } : {}),
...(meta ? { meta } : {}),
Expand Down

0 comments on commit a441002

Please sign in to comment.