-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add missing endpoints & update docs * Update docs * Update useBlocks.tsx * Update docs * Update types * Update useBlockRenderer.tsx * v2.0.0 alpha 1 * Update * Update devDependencies * v2.0.0 beta 2 * Update devDependencies * Fix post, update & delete methods incorrect options error * v2.0.0 beta 3 * v2.0.0
- Loading branch information
Showing
9 changed files
with
519 additions
and
330 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export declare const serialize: (object: any) => string; | ||
export declare const serialize: (options: any) => string; | ||
export declare const optionsToBody: (options: object) => URLSearchParams; |
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 |
---|---|---|
@@ -1,13 +1,29 @@ | ||
export const serialize = (object: any): string => { | ||
export const serialize = (options: any): string => { | ||
const string: string[] = []; | ||
|
||
for (let key in object) { | ||
if (object.hasOwnProperty(key)) { | ||
for (let key in options) { | ||
if (options.hasOwnProperty(key)) { | ||
string.push( | ||
`${encodeURIComponent(key)}=${encodeURIComponent(object[key])}` | ||
`${encodeURIComponent(key)}=${encodeURIComponent(options[key])}` | ||
); | ||
} | ||
} | ||
|
||
return string.length > 0 ? '?' + string.join('&') : ''; | ||
}; | ||
|
||
export const optionsToBody = (options: object) => { | ||
if (!options) { | ||
return options; | ||
} | ||
|
||
const params = Object.entries(options); | ||
|
||
const urlencoded = new URLSearchParams(); | ||
|
||
for (let [key, value] of params) { | ||
urlencoded.append(key, value); | ||
} | ||
|
||
return urlencoded; | ||
}; |
Oops, something went wrong.