You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @returns {string} Key name in nested query-param format with optional array style suffix
24
+
* @private
25
+
*/
26
+
exportfunctionparamKeyName(param){
27
+
if(['[]',']['].includes(param.slice(-2))){
28
+
return`[${param.slice(0,-2)}][]`
29
+
}
30
+
31
+
return`[${param}]`
32
+
}
33
+
15
34
/**
16
35
* Constructs a URL query string for JSON:API parameters
17
36
*
18
37
* @param {Object} [params] Parameters to parse
19
38
* @param {string} [prefix] Prefix for nested parameters - used internally
39
+
* @param {boolean} [traditional=true] Use the traditional (default) or modern param serializer. Set to false if your server is running Ruby on Rails or other modern web frameworks
20
40
* @returns {string} URL query string
21
41
*
22
42
* @example
@@ -31,12 +51,13 @@ function queryFormat (value, key) {
Copy file name to clipboardExpand all lines: packages/kitsu/src/index.js
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,7 @@ import pluralise from 'pluralize'
8
8
* @param {Object} [options] Options
9
9
* @param {string} [options.baseURL=https://kitsu.io/api/edge] Set the API endpoint
10
10
* @param {Object} [options.headers] Additional headers to send with the requests
11
+
* @param {'traditional'|'modern'|Function} [options.query=traditional] Query serializer function to use. This will impact the say keys are serialized when passing arrays as query parameters. 'modern' is recommended for new projects.
11
12
* @param {boolean} [options.camelCaseTypes=true] If enabled, `type` will be converted to camelCase from kebab-casae or snake_case
12
13
* @param {'kebab'|'snake'|'none'} [options.resourceCase=kebab] Case to convert camelCase to. `kebab` - `/library-entries`; `snake` - /library_entries`; `none` - `/libraryEntries`
13
14
* @param {boolean} [options.pluralize=true] If enabled, `/user` will become `/users` in the URL request and `type` will be pluralized in POST, PATCH and DELETE requests
@@ -29,6 +30,11 @@ import pluralise from 'pluralize'
0 commit comments