Created
March 23, 2023 20:49
-
-
Save codebutler/4fa8f6ff7c9cb51d5be7e4345054cbf1 to your computer and use it in GitHub Desktop.
String array query parameters with axios + django-rest-framework
This file contains hidden or 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
const api = axios.create({ | |
// other options... | |
paramsSerializer: { | |
// drf expects array params to be repeated, e.g. ?foo=bar&foo=baz | |
// the default behavior is to serialize them as foo[]=bar&foo[]=baz | |
serialize: (params) => qs.stringify(params, { arrayFormat: "repeat" }), | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment