-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supporting body types like FormData and URLSearchParams resolves #36
- Loading branch information
Showing
5 changed files
with
788 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const payloadMethods = new Set(Object.freeze(['PATCH', 'POST', 'PUT', 'DELETE'])) | ||
export function isPayloadMethod (method: string = 'GET') { | ||
return payloadMethods.has(method.toUpperCase()) | ||
} | ||
|
||
export function isJSONSerializable (val: any) { | ||
if (val === undefined) { | ||
return false | ||
} | ||
const t = typeof val | ||
if (t === 'string' || t === 'number' || t === 'boolean' || t === null) { | ||
return true | ||
} | ||
if (t !== 'object') { | ||
return false // bigint, function, symbol, undefined | ||
} | ||
if (Array.isArray(val)) { | ||
return true | ||
} | ||
return val.constructor?.name === 'Object' || typeof val.toJSON === 'function' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.