From 32daeb8bc48a4bf4a7e3ddadf5acf78923806883 Mon Sep 17 00:00:00 2001 From: Abhinav Srivastava Date: Mon, 16 Sep 2019 11:07:52 +0530 Subject: [PATCH 1/3] Post request with empty body, now working fine. --- src/GraphRequestUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphRequestUtil.ts b/src/GraphRequestUtil.ts index c58062ad7..ab0ffae8f 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 ? null : content.constructor.name; if (className === "Buffer" || className === "Blob" || className === "File" || className === "FormData" || typeof content === "string") { return content; } From 6850658762018c46c3a4d01368d5d8300139ca09 Mon Sep 17 00:00:00 2001 From: Abhinav Srivastava Date: Mon, 16 Sep 2019 16:22:13 +0530 Subject: [PATCH 2/3] updated the tests for this case --- spec/core/GraphRequestUtil.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); + }); }); }); From 2ebf66635d8b4c7d63d4a5b17c42d68149ab9137 Mon Sep 17 00:00:00 2001 From: Abhinav Srivastava Date: Tue, 17 Sep 2019 10:45:11 +0530 Subject: [PATCH 3/3] made change to use undefined instead of null as classname --- src/GraphRequestUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphRequestUtil.ts b/src/GraphRequestUtil.ts index ab0ffae8f..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 === undefined ? null : 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; }