Skip to content

Commit

Permalink
Merge pull request microsoftgraph#229 from microsoftgraph/abhsriva/em…
Browse files Browse the repository at this point in the history
…ptyPostRequest

Post request with empty body, now working fine.
  • Loading branch information
krototype authored Oct 3, 2019
2 parents 2ec9a2f + 2ebf666 commit 7baaf98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion spec/core/GraphRequestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
2 changes: 1 addition & 1 deletion src/GraphRequestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7baaf98

Please sign in to comment.