diff --git a/spec/core/GraphRequestUtil.ts b/spec/core/GraphRequestUtil.ts index 6ce3dff82..021ef1905 100644 --- a/spec/core/GraphRequestUtil.ts +++ b/spec/core/GraphRequestUtil.ts @@ -61,10 +61,15 @@ describe("GraphRequestUtil.ts", () => { node2.link = node1; try { serializeContent(node1); - throw new Error("Something wrong with the serialize content, it should stringify cyclic referenced objects"); + throw new Error("Something wrong with the serialize content, it should not stringify cyclic referenced objects"); } catch (error) { assert.equal(error.message, "Unable to stringify the content"); } }); + + it("Should return undefined for the case of undefined content value", () => { + const val = undefined; + assert.equal(serializeContent(val), undefined); + }); }); }); diff --git a/src/GraphRequestUtil.ts b/src/GraphRequestUtil.ts index c58062ad7..c2afee5a5 100644 --- a/src/GraphRequestUtil.ts +++ b/src/GraphRequestUtil.ts @@ -41,7 +41,7 @@ export const urlJoin = (urlSegments: string[]): string => { */ export const serializeContent = (content: any): any => { - const className: string = content.constructor.name; + const className: string = content === undefined ? undefined : content.constructor.name; if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") { return content; }